mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-04-28 17:32:38 +02:00
For more information about the rationale, this was [discussed](https://github.com/spiral-project/ihatemoney/issues/1232#issuecomment-2081517453) in our bugtracker.
72 lines
1.8 KiB
Python
72 lines
1.8 KiB
Python
"""Add currencies
|
|
|
|
Revision ID: 927ed575acbd
|
|
Revises: cb038f79982e
|
|
Create Date: 2020-04-25 14:49:41.136602
|
|
|
|
"""
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "927ed575acbd"
|
|
down_revision = "cb038f79982e"
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.add_column("bill", sa.Column("converted_amount", sa.Float(), nullable=True))
|
|
op.add_column(
|
|
"bill",
|
|
sa.Column(
|
|
"original_currency",
|
|
sa.String(length=3),
|
|
server_default="",
|
|
nullable=True,
|
|
),
|
|
)
|
|
op.add_column(
|
|
"bill_version",
|
|
sa.Column("converted_amount", sa.Float(), autoincrement=False, nullable=True),
|
|
)
|
|
op.add_column(
|
|
"bill_version",
|
|
sa.Column(
|
|
"original_currency", sa.String(length=3), autoincrement=False, nullable=True
|
|
),
|
|
)
|
|
op.add_column(
|
|
"project",
|
|
sa.Column(
|
|
"default_currency",
|
|
sa.String(length=3),
|
|
server_default="",
|
|
nullable=True,
|
|
),
|
|
)
|
|
op.add_column(
|
|
"project_version",
|
|
sa.Column(
|
|
"default_currency", sa.String(length=3), autoincrement=False, nullable=True
|
|
),
|
|
)
|
|
# ### end Alembic commands ###
|
|
op.execute(
|
|
"""
|
|
UPDATE bill
|
|
SET converted_amount = amount
|
|
WHERE converted_amount IS NULL
|
|
"""
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_column("project_version", "default_currency")
|
|
op.drop_column("project", "default_currency")
|
|
op.drop_column("bill_version", "original_currency")
|
|
op.drop_column("bill_version", "converted_amount")
|
|
op.drop_column("bill", "original_currency")
|
|
op.drop_column("bill", "converted_amount")
|
|
# ### end Alembic commands ###
|