aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'ihatemoney/migrations')
-rwxr-xr-xihatemoney/migrations/env.py33
-rw-r--r--ihatemoney/migrations/versions/26d6a218c329_.py8
-rw-r--r--ihatemoney/migrations/versions/6c6fb2b7f229_.py8
-rw-r--r--ihatemoney/migrations/versions/a67119aa3ee5_migrate_negative_weights.py26
-rw-r--r--ihatemoney/migrations/versions/afbf27e6ef20_add_bill_import_date_field.py8
-rw-r--r--ihatemoney/migrations/versions/b78f8a8bdb16_hash_project_passwords.py25
-rw-r--r--ihatemoney/migrations/versions/b9a10d5d63ce_.py85
-rw-r--r--ihatemoney/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py25
8 files changed, 114 insertions, 104 deletions
diff --git a/ihatemoney/migrations/env.py b/ihatemoney/migrations/env.py
index e2f9a28..4d4729c 100755
--- a/ihatemoney/migrations/env.py
+++ b/ihatemoney/migrations/env.py
@@ -11,14 +11,16 @@ config = context.config
# Interpret the config file for Python logging. This line sets up loggers
# basically.
fileConfig(config.config_file_name)
-logger = logging.getLogger('alembic.env')
+logger = logging.getLogger("alembic.env")
# Add your model's MetaData object here for 'autogenerate' support from myapp
# import mymodel target_metadata = mymodel.Base.metadata.
from flask import current_app
-config.set_main_option('sqlalchemy.url',
- current_app.config.get('SQLALCHEMY_DATABASE_URI'))
-target_metadata = current_app.extensions['migrate'].db.metadata
+
+config.set_main_option(
+ "sqlalchemy.url", current_app.config.get("SQLALCHEMY_DATABASE_URI")
+)
+target_metadata = current_app.extensions["migrate"].db.metadata
# Other values from the config, defined by the needs of env.py,
# can be acquired:
@@ -57,21 +59,25 @@ def run_migrations_online():
# when there are no changes to the schema.
# reference: https://alembic.readthedocs.io/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
- if getattr(config.cmd_opts, 'autogenerate', False):
+ if getattr(config.cmd_opts, "autogenerate", False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
- logger.info('No changes in schema detected.')
+ logger.info("No changes in schema detected.")
- engine = engine_from_config(config.get_section(config.config_ini_section),
- prefix='sqlalchemy.',
- poolclass=pool.NullPool)
+ engine = engine_from_config(
+ config.get_section(config.config_ini_section),
+ prefix="sqlalchemy.",
+ poolclass=pool.NullPool,
+ )
connection = engine.connect()
- context.configure(connection=connection,
- target_metadata=target_metadata,
- process_revision_directives=process_revision_directives,
- **current_app.extensions['migrate'].configure_args)
+ context.configure(
+ connection=connection,
+ target_metadata=target_metadata,
+ process_revision_directives=process_revision_directives,
+ **current_app.extensions["migrate"].configure_args
+ )
try:
with context.begin_transaction():
@@ -79,6 +85,7 @@ def run_migrations_online():
finally:
connection.close()
+
if context.is_offline_mode():
run_migrations_offline()
else:
diff --git a/ihatemoney/migrations/versions/26d6a218c329_.py b/ihatemoney/migrations/versions/26d6a218c329_.py
index 859b9af..6d5e237 100644
--- a/ihatemoney/migrations/versions/26d6a218c329_.py
+++ b/ihatemoney/migrations/versions/26d6a218c329_.py
@@ -7,8 +7,8 @@ Create Date: 2016-06-15 09:22:04.069447
"""
# revision identifiers, used by Alembic.
-revision = '26d6a218c329'
-down_revision = 'b9a10d5d63ce'
+revision = "26d6a218c329"
+down_revision = "b9a10d5d63ce"
from alembic import op
import sqlalchemy as sa
@@ -16,11 +16,11 @@ import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
- op.add_column('person', sa.Column('weight', sa.Float(), nullable=True))
+ 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')
+ op.drop_column("person", "weight")
### end Alembic commands ###
diff --git a/ihatemoney/migrations/versions/6c6fb2b7f229_.py b/ihatemoney/migrations/versions/6c6fb2b7f229_.py
index 0336f6c..da31578 100644
--- a/ihatemoney/migrations/versions/6c6fb2b7f229_.py
+++ b/ihatemoney/migrations/versions/6c6fb2b7f229_.py
@@ -7,8 +7,8 @@ Create Date: 2019-09-28 13:38:09.550747
"""
# revision identifiers, used by Alembic.
-revision = '6c6fb2b7f229'
-down_revision = 'a67119aa3ee5'
+revision = "6c6fb2b7f229"
+down_revision = "a67119aa3ee5"
from alembic import op
import sqlalchemy as sa
@@ -16,11 +16,11 @@ import sqlalchemy as sa
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
- op.add_column('bill', sa.Column('external_link', sa.UnicodeText(), nullable=True))
+ op.add_column("bill", sa.Column("external_link", sa.UnicodeText(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
- op.drop_column('bill', 'external_link')
+ op.drop_column("bill", "external_link")
# ### end Alembic commands ###
diff --git a/ihatemoney/migrations/versions/a67119aa3ee5_migrate_negative_weights.py b/ihatemoney/migrations/versions/a67119aa3ee5_migrate_negative_weights.py
index ec23470..8061896 100644
--- a/ihatemoney/migrations/versions/a67119aa3ee5_migrate_negative_weights.py
+++ b/ihatemoney/migrations/versions/a67119aa3ee5_migrate_negative_weights.py
@@ -7,29 +7,29 @@ Create Date: 2018-12-25 18:34:20.220844
"""
# revision identifiers, used by Alembic.
-revision = 'a67119aa3ee5'
-down_revision = 'afbf27e6ef20'
+revision = "a67119aa3ee5"
+down_revision = "afbf27e6ef20"
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')
+ "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 <= 0)
- .values(weight=1)
+ person_helper.update().where(person_helper.c.weight <= 0).values(weight=1)
)
diff --git a/ihatemoney/migrations/versions/afbf27e6ef20_add_bill_import_date_field.py b/ihatemoney/migrations/versions/afbf27e6ef20_add_bill_import_date_field.py
index 4179155..0ccfac2 100644
--- a/ihatemoney/migrations/versions/afbf27e6ef20_add_bill_import_date_field.py
+++ b/ihatemoney/migrations/versions/afbf27e6ef20_add_bill_import_date_field.py
@@ -7,8 +7,8 @@ Create Date: 2018-02-19 20:29:26.286136
"""
# revision identifiers, used by Alembic.
-revision = 'afbf27e6ef20'
-down_revision = 'b78f8a8bdb16'
+revision = "afbf27e6ef20"
+down_revision = "b78f8a8bdb16"
from alembic import op
import sqlalchemy as sa
@@ -16,11 +16,11 @@ import sqlalchemy as sa
def upgrade():
### commands auto generated by Alembic - please adjust! ###
- op.add_column('bill', sa.Column('creation_date', sa.Date(), nullable=True))
+ op.add_column("bill", sa.Column("creation_date", sa.Date(), nullable=True))
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
- op.drop_column('bill', 'creation_date')
+ op.drop_column("bill", "creation_date")
### end Alembic commands ###
diff --git a/ihatemoney/migrations/versions/b78f8a8bdb16_hash_project_passwords.py b/ihatemoney/migrations/versions/b78f8a8bdb16_hash_project_passwords.py
index e32983d..e730b8d 100644
--- a/ihatemoney/migrations/versions/b78f8a8bdb16_hash_project_passwords.py
+++ b/ihatemoney/migrations/versions/b78f8a8bdb16_hash_project_passwords.py
@@ -7,20 +7,21 @@ Create Date: 2017-12-17 11:45:44.783238
"""
# revision identifiers, used by Alembic.
-revision = 'b78f8a8bdb16'
-down_revision = 'f629c8ef4ab0'
+revision = "b78f8a8bdb16"
+down_revision = "f629c8ef4ab0"
from alembic import op
import sqlalchemy as sa
from werkzeug.security import generate_password_hash
project_helper = sa.Table(
- 'project', sa.MetaData(),
- 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')
+ "project",
+ sa.MetaData(),
+ 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"),
)
@@ -28,11 +29,9 @@ def upgrade():
connection = op.get_bind()
for project in connection.execute(project_helper.select()):
connection.execute(
- project_helper.update().where(
- project_helper.c.name == project.name
- ).values(
- password=generate_password_hash(project.password)
- )
+ project_helper.update()
+ .where(project_helper.c.name == project.name)
+ .values(password=generate_password_hash(project.password))
)
diff --git a/ihatemoney/migrations/versions/b9a10d5d63ce_.py b/ihatemoney/migrations/versions/b9a10d5d63ce_.py
index 92bb446..3c92780 100644
--- a/ihatemoney/migrations/versions/b9a10d5d63ce_.py
+++ b/ihatemoney/migrations/versions/b9a10d5d63ce_.py
@@ -7,7 +7,7 @@ Create Date: 2016-05-21 23:21:21.605076
"""
# revision identifiers, used by Alembic.
-revision = 'b9a10d5d63ce'
+revision = "b9a10d5d63ce"
down_revision = None
from alembic import op
@@ -16,53 +16,58 @@ 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(
+ "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(
+ "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(
+ "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(
+ "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'], )
+ 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')
+ 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
index 5542146..481c2d9 100644
--- a/ihatemoney/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py
+++ b/ihatemoney/migrations/versions/f629c8ef4ab0_initialize_all_members_weights_to_1.py
@@ -7,30 +7,29 @@ Create Date: 2016-06-15 09:40:30.400862
"""
# revision identifiers, used by Alembic.
-revision = 'f629c8ef4ab0'
-down_revision = '26d6a218c329'
+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')
+ "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)
+ person_helper.update().where(person_helper.c.weight == None).values(weight=1)
)