aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/migrations/versions
diff options
context:
space:
mode:
Diffstat (limited to 'ihatemoney/migrations/versions')
-rw-r--r--ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py214
-rw-r--r--ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py50
2 files changed, 264 insertions, 0 deletions
diff --git a/ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py b/ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py
new file mode 100644
index 0000000..0800835
--- /dev/null
+++ b/ihatemoney/migrations/versions/2dcb0c0048dc_autologger.py
@@ -0,0 +1,214 @@
+"""autologger
+
+Revision ID: 2dcb0c0048dc
+Revises: 6c6fb2b7f229
+Create Date: 2020-04-10 18:12:41.285590
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "2dcb0c0048dc"
+down_revision = "6c6fb2b7f229"
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.create_table(
+ "bill_version",
+ sa.Column("id", sa.Integer(), autoincrement=False, nullable=False),
+ sa.Column("payer_id", sa.Integer(), autoincrement=False, nullable=True),
+ sa.Column("amount", sa.Float(), autoincrement=False, nullable=True),
+ sa.Column("date", sa.Date(), autoincrement=False, nullable=True),
+ sa.Column("creation_date", sa.Date(), autoincrement=False, nullable=True),
+ sa.Column("what", sa.UnicodeText(), autoincrement=False, nullable=True),
+ sa.Column(
+ "external_link", sa.UnicodeText(), autoincrement=False, nullable=True
+ ),
+ sa.Column("archive", sa.Integer(), autoincrement=False, nullable=True),
+ sa.Column(
+ "transaction_id", sa.BigInteger(), autoincrement=False, nullable=False
+ ),
+ sa.Column("end_transaction_id", sa.BigInteger(), nullable=True),
+ sa.Column("operation_type", sa.SmallInteger(), nullable=False),
+ sa.PrimaryKeyConstraint("id", "transaction_id"),
+ )
+ op.create_index(
+ op.f("ix_bill_version_end_transaction_id"),
+ "bill_version",
+ ["end_transaction_id"],
+ unique=False,
+ )
+ op.create_index(
+ op.f("ix_bill_version_operation_type"),
+ "bill_version",
+ ["operation_type"],
+ unique=False,
+ )
+ op.create_index(
+ op.f("ix_bill_version_transaction_id"),
+ "bill_version",
+ ["transaction_id"],
+ unique=False,
+ )
+ op.create_table(
+ "billowers_version",
+ sa.Column("bill_id", sa.Integer(), autoincrement=False, nullable=False),
+ sa.Column("person_id", sa.Integer(), autoincrement=False, nullable=False),
+ sa.Column(
+ "transaction_id", sa.BigInteger(), autoincrement=False, nullable=False
+ ),
+ sa.Column("end_transaction_id", sa.BigInteger(), nullable=True),
+ sa.Column("operation_type", sa.SmallInteger(), nullable=False),
+ sa.PrimaryKeyConstraint("bill_id", "person_id", "transaction_id"),
+ )
+ op.create_index(
+ op.f("ix_billowers_version_end_transaction_id"),
+ "billowers_version",
+ ["end_transaction_id"],
+ unique=False,
+ )
+ op.create_index(
+ op.f("ix_billowers_version_operation_type"),
+ "billowers_version",
+ ["operation_type"],
+ unique=False,
+ )
+ op.create_index(
+ op.f("ix_billowers_version_transaction_id"),
+ "billowers_version",
+ ["transaction_id"],
+ unique=False,
+ )
+ op.create_table(
+ "person_version",
+ sa.Column("id", sa.Integer(), autoincrement=False, nullable=False),
+ sa.Column(
+ "project_id", sa.String(length=64), autoincrement=False, nullable=True
+ ),
+ sa.Column("name", sa.UnicodeText(), autoincrement=False, nullable=True),
+ sa.Column("weight", sa.Float(), autoincrement=False, nullable=True),
+ sa.Column("activated", sa.Boolean(), autoincrement=False, nullable=True),
+ sa.Column(
+ "transaction_id", sa.BigInteger(), autoincrement=False, nullable=False
+ ),
+ sa.Column("end_transaction_id", sa.BigInteger(), nullable=True),
+ sa.Column("operation_type", sa.SmallInteger(), nullable=False),
+ sa.PrimaryKeyConstraint("id", "transaction_id"),
+ )
+ op.create_index(
+ op.f("ix_person_version_end_transaction_id"),
+ "person_version",
+ ["end_transaction_id"],
+ unique=False,
+ )
+ op.create_index(
+ op.f("ix_person_version_operation_type"),
+ "person_version",
+ ["operation_type"],
+ unique=False,
+ )
+ op.create_index(
+ op.f("ix_person_version_transaction_id"),
+ "person_version",
+ ["transaction_id"],
+ unique=False,
+ )
+ op.create_table(
+ "project_version",
+ sa.Column("id", sa.String(length=64), autoincrement=False, nullable=False),
+ sa.Column("name", sa.UnicodeText(), autoincrement=False, nullable=True),
+ sa.Column(
+ "password", sa.String(length=128), autoincrement=False, nullable=True
+ ),
+ sa.Column(
+ "contact_email", sa.String(length=128), autoincrement=False, nullable=True
+ ),
+ sa.Column(
+ "logging_preference",
+ sa.Enum("DISABLED", "ENABLED", "RECORD_IP", name="loggingmode"),
+ server_default="ENABLED",
+ autoincrement=False,
+ nullable=True,
+ ),
+ sa.Column(
+ "transaction_id", sa.BigInteger(), autoincrement=False, nullable=False
+ ),
+ sa.Column("end_transaction_id", sa.BigInteger(), nullable=True),
+ sa.Column("operation_type", sa.SmallInteger(), nullable=False),
+ sa.PrimaryKeyConstraint("id", "transaction_id"),
+ )
+ op.create_index(
+ op.f("ix_project_version_end_transaction_id"),
+ "project_version",
+ ["end_transaction_id"],
+ unique=False,
+ )
+ op.create_index(
+ op.f("ix_project_version_operation_type"),
+ "project_version",
+ ["operation_type"],
+ unique=False,
+ )
+ op.create_index(
+ op.f("ix_project_version_transaction_id"),
+ "project_version",
+ ["transaction_id"],
+ unique=False,
+ )
+ op.create_table(
+ "transaction",
+ sa.Column("issued_at", sa.DateTime(), nullable=True),
+ sa.Column("id", sa.BigInteger(), autoincrement=True, nullable=False),
+ sa.Column("remote_addr", sa.String(length=50), nullable=True),
+ sa.PrimaryKeyConstraint("id"),
+ )
+ op.add_column(
+ "project",
+ sa.Column(
+ "logging_preference",
+ sa.Enum("DISABLED", "ENABLED", "RECORD_IP", name="loggingmode"),
+ server_default="ENABLED",
+ nullable=False,
+ ),
+ )
+ # ### end Alembic commands ###
+
+
+def downgrade():
+ # ### commands auto generated by Alembic - please adjust! ###
+ op.drop_column("project", "logging_preference")
+ op.drop_table("transaction")
+ op.drop_index(
+ op.f("ix_project_version_transaction_id"), table_name="project_version"
+ )
+ op.drop_index(
+ op.f("ix_project_version_operation_type"), table_name="project_version"
+ )
+ op.drop_index(
+ op.f("ix_project_version_end_transaction_id"), table_name="project_version"
+ )
+ op.drop_table("project_version")
+ op.drop_index(op.f("ix_person_version_transaction_id"), table_name="person_version")
+ op.drop_index(op.f("ix_person_version_operation_type"), table_name="person_version")
+ op.drop_index(
+ op.f("ix_person_version_end_transaction_id"), table_name="person_version"
+ )
+ op.drop_table("person_version")
+ op.drop_index(
+ op.f("ix_billowers_version_transaction_id"), table_name="billowers_version"
+ )
+ op.drop_index(
+ op.f("ix_billowers_version_operation_type"), table_name="billowers_version"
+ )
+ op.drop_index(
+ op.f("ix_billowers_version_end_transaction_id"), table_name="billowers_version"
+ )
+ op.drop_table("billowers_version")
+ op.drop_index(op.f("ix_bill_version_transaction_id"), table_name="bill_version")
+ op.drop_index(op.f("ix_bill_version_operation_type"), table_name="bill_version")
+ op.drop_index(op.f("ix_bill_version_end_transaction_id"), table_name="bill_version")
+ op.drop_table("bill_version")
+ # ### end Alembic commands ###
diff --git a/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py b/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py
new file mode 100644
index 0000000..ae5ab32
--- /dev/null
+++ b/ihatemoney/migrations/versions/cb038f79982e_sqlite_autoincrement.py
@@ -0,0 +1,50 @@
+"""sqlite_autoincrement
+
+Revision ID: cb038f79982e
+Revises: 2dcb0c0048dc
+Create Date: 2020-04-13 17:40:02.426957
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = "cb038f79982e"
+down_revision = "2dcb0c0048dc"
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+ alter_table_batches = [
+ op.batch_alter_table(
+ "person", recreate="always", table_kwargs={"sqlite_autoincrement": True}
+ ),
+ op.batch_alter_table(
+ "bill", recreate="always", table_kwargs={"sqlite_autoincrement": True}
+ ),
+ op.batch_alter_table(
+ "billowers", recreate="always", table_kwargs={"sqlite_autoincrement": True}
+ ),
+ ]
+
+ for batch_op in alter_table_batches:
+ with batch_op:
+ pass
+
+
+def downgrade():
+ alter_table_batches = [
+ op.batch_alter_table(
+ "person", recreate="always", table_kwargs={"sqlite_autoincrement": False}
+ ),
+ op.batch_alter_table(
+ "bill", recreate="always", table_kwargs={"sqlite_autoincrement": False}
+ ),
+ op.batch_alter_table(
+ "billowers", recreate="always", table_kwargs={"sqlite_autoincrement": False}
+ ),
+ ]
+
+ for batch_op in alter_table_batches:
+ with batch_op:
+ pass