[PATCH 5/6] Add alembic revision to update the database scheme

Pierre-Yves Chibon pingou at pingoured.fr
Mon Jan 7 20:26:16 UTC 2013


---
 .../versions/32ba137a3d56_add_token_informatio.py  |   33 ++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100644 coprs_frontend/alembic/versions/32ba137a3d56_add_token_informatio.py

diff --git a/coprs_frontend/alembic/versions/32ba137a3d56_add_token_informatio.py b/coprs_frontend/alembic/versions/32ba137a3d56_add_token_informatio.py
new file mode 100644
index 0000000..99e3413
--- /dev/null
+++ b/coprs_frontend/alembic/versions/32ba137a3d56_add_token_informatio.py
@@ -0,0 +1,33 @@
+"""Add token information to the user table
+
+Revision ID: 32ba137a3d56
+Revises: 595a31c145fb
+Create Date: 2013-01-07 20:56:14.698735
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '32ba137a3d56'
+down_revision = '595a31c145fb'
+
+from alembic import op
+import sqlalchemy as sa
+
+import datetime
+
+
+def upgrade():
+    """ Add the coluns api_token and api_token_expiration to the user table.
+    """
+    op.add_column('user', sa.Column('api_token', sa.String(40),
+        nullable=False))
+    op.add_column('user', sa.Column('api_token_expiration', sa.Date,
+        nullable=False, default=datetime.date.today()))
+
+
+def downgrade():
+    """ Drop the coluns api_token and api_token_expiration to the user table.
+    """
+    op.drop_column('user', 'api_token')
+    op.drop_column('user', 'api_token_expiration')
+
-- 
1.7.1



More information about the copr-devel mailing list