aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/migrations/versions
diff options
context:
space:
mode:
Diffstat (limited to 'ihatemoney/migrations/versions')
-rw-r--r--ihatemoney/migrations/versions/26d6a218c329_.py26
-rw-r--r--ihatemoney/migrations/versions/b9a10d5d63ce_.py68
-rw-r--r--ihatemoney/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py39
3 files changed, 133 insertions, 0 deletions
diff --git a/ihatemoney/migrations/versions/26d6a218c329_.py b/ihatemoney/migrations/versions/26d6a218c329_.py
new file mode 100644
index 0000000..859b9af
--- /dev/null
+++ b/ihatemoney/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/ihatemoney/migrations/versions/b9a10d5d63ce_.py b/ihatemoney/migrations/versions/b9a10d5d63ce_.py
new file mode 100644
index 0000000..92bb446
--- /dev/null
+++ b/ihatemoney/migrations/versions/b9a10d5d63ce_.py
@@ -0,0 +1,68 @@
+"""Initial migration
+
+Revision ID: b9a10d5d63ce
+Revises: None
+Create Date: 2016-05-21 23:21:21.605076
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'b9a10d5d63ce'
+down_revision = None
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ ### commands auto generated by Alembic - please adjust! ###
+ op.create_table('project',
+ sa.Column('id', sa.String(length=64), nullable=False),
+ sa.Column('name', sa.UnicodeText(), nullable=True),
+ sa.Column('password', sa.String(length=128), nullable=True),
+ sa.Column('contact_email', sa.String(length=128), nullable=True),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('archive',
+ 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.ForeignKeyConstraint(['project_id'], ['project.id'], ),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('person',
+ 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.ForeignKeyConstraint(['project_id'], ['project.id'], ),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('bill',
+ sa.Column('id', sa.Integer(), nullable=False),
+ sa.Column('payer_id', sa.Integer(), nullable=True),
+ sa.Column('amount', sa.Float(), nullable=True),
+ sa.Column('date', sa.Date(), nullable=True),
+ sa.Column('what', sa.UnicodeText(), nullable=True),
+ sa.Column('archive', sa.Integer(), nullable=True),
+ sa.ForeignKeyConstraint(['archive'], ['archive.id'], ),
+ sa.ForeignKeyConstraint(['payer_id'], ['person.id'], ),
+ sa.PrimaryKeyConstraint('id')
+ )
+ op.create_table('billowers',
+ sa.Column('bill_id', sa.Integer(), nullable=True),
+ sa.Column('person_id', sa.Integer(), nullable=True),
+ sa.ForeignKeyConstraint(['bill_id'], ['bill.id'], ),
+ sa.ForeignKeyConstraint(['person_id'], ['person.id'], )
+ )
+ ### end Alembic commands ###
+
+
+def downgrade():
+ ### commands auto generated by Alembic - please adjust! ###
+ op.drop_table('billowers')
+ op.drop_table('bill')
+ op.drop_table('person')
+ op.drop_table('archive')
+ op.drop_table('project')
+ ### end Alembic commands ###
diff --git a/ihatemoney/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py b/ihatemoney/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py
new file mode 100644
index 0000000..5542146
--- /dev/null
+++ b/ihatemoney/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