aboutsummaryrefslogtreecommitdiff
path: root/budget/migrations/versions
diff options
context:
space:
mode:
Diffstat (limited to 'budget/migrations/versions')
-rw-r--r--budget/migrations/versions/26d6a218c329_.py26
-rw-r--r--budget/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py39
2 files changed, 65 insertions, 0 deletions
diff --git a/budget/migrations/versions/26d6a218c329_.py b/budget/migrations/versions/26d6a218c329_.py
new file mode 100644
index 0000000..859b9af
--- /dev/null
+++ b/budget/migrations/versions/26d6a218c329_.py
@@ -0,0 +1,26 @@
+"""Add Person.weight column
+
+Revision ID: 26d6a218c329
+Revises: b9a10d5d63ce
+Create Date: 2016-06-15 09:22:04.069447
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '26d6a218c329'
+down_revision = 'b9a10d5d63ce'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ ### commands auto generated by Alembic - please adjust! ###
+ op.add_column('person', sa.Column('weight', sa.Float(), nullable=True))
+ ### end Alembic commands ###
+
+
+def downgrade():
+ ### commands auto generated by Alembic - please adjust! ###
+ op.drop_column('person', 'weight')
+ ### end Alembic commands ###
diff --git a/budget/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py b/budget/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py
new file mode 100644
index 0000000..5542146
--- /dev/null
+++ b/budget/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py
@@ -0,0 +1,39 @@
+"""Initialize all members weights to 1
+
+Revision ID: f629c8ef4ab0
+Revises: 26d6a218c329
+Create Date: 2016-06-15 09:40:30.400862
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'f629c8ef4ab0'
+down_revision = '26d6a218c329'
+
+from alembic import op
+import sqlalchemy as sa
+
+# Snapshot of the person table
+person_helper = sa.Table(
+ 'person', sa.MetaData(),
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('project_id', sa.String(length=64), nullable=True),
+ sa.Column('name', sa.UnicodeText(), nullable=True),
+ sa.Column('activated', sa.Boolean(), nullable=True),
+ sa.Column('weight', sa.Float(), nullable=True),
+ sa.ForeignKeyConstraint(['project_id'], ['project.id'], ),
+ sa.PrimaryKeyConstraint('id')
+)
+
+
+def upgrade():
+ op.execute(
+ person_helper.update()
+ .where(person_helper.c.weight == None)
+ .values(weight=1)
+ )
+
+
+def downgrade():
+ # Downgrade path is not possible, because information has been lost.
+ pass