mirror of https://github.com/rhaamo/omnomnomnom
11 changed files with 155 additions and 12 deletions
@ -0,0 +1,48 @@ |
|||
"""Add item and sub item |
|||
|
|||
Revision ID: 23580c5fc67e |
|||
Revises: 77dc08b8493f |
|||
Create Date: 2020-08-10 08:23:31.139463 |
|||
|
|||
""" |
|||
from alembic import op # noqa: E402 |
|||
import sqlalchemy as sa # noqa: E402 |
|||
from sqlalchemy.dialects import postgresql |
|||
|
|||
# revision identifiers, used by Alembic. |
|||
revision = "23580c5fc67e" |
|||
down_revision = "77dc08b8493f" |
|||
branch_labels = None |
|||
depends_on = None |
|||
|
|||
|
|||
def upgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
op.create_table( |
|||
"item", |
|||
sa.Column("id", sa.Integer(), nullable=False), |
|||
sa.Column("qty", sa.Integer(), nullable=True), |
|||
sa.Column("expiry", sa.DateTime(), nullable=True), |
|||
sa.Column("flake_id", postgresql.UUID(as_uuid=True), nullable=True), |
|||
sa.Column("created_at", sa.DateTime(), nullable=True), |
|||
sa.Column("openfoodfacts_product", postgresql.JSONB(astext_type=sa.Text()), nullable=True), |
|||
sa.PrimaryKeyConstraint("id"), |
|||
) |
|||
op.create_table( |
|||
"sub_item", |
|||
sa.Column("id", sa.Integer(), nullable=False), |
|||
sa.Column("qty", sa.Integer(), nullable=True), |
|||
sa.Column("expiry", sa.DateTime(), nullable=True), |
|||
sa.Column("created_at", sa.DateTime(), nullable=True), |
|||
sa.Column("item_id", sa.Integer(), nullable=False), |
|||
sa.ForeignKeyConstraint(["item_id"], ["item.id"],), |
|||
sa.PrimaryKeyConstraint("id"), |
|||
) |
|||
# ### end Alembic commands ### |
|||
|
|||
|
|||
def downgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
op.drop_table("sub_item") |
|||
op.drop_table("item") |
|||
# ### end Alembic commands ### |
@ -0,0 +1,30 @@ |
|||
"""Remove useless fields |
|||
|
|||
Revision ID: 71744666aed6 |
|||
Revises: 23580c5fc67e |
|||
Create Date: 2020-08-10 08:30:43.759215 |
|||
|
|||
""" |
|||
from alembic import op # noqa: E402 |
|||
import sqlalchemy as sa # noqa: E402 |
|||
from sqlalchemy.dialects import postgresql |
|||
|
|||
# revision identifiers, used by Alembic. |
|||
revision = '71744666aed6' |
|||
down_revision = '23580c5fc67e' |
|||
branch_labels = None |
|||
depends_on = None |
|||
|
|||
|
|||
def upgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
op.drop_column('item', 'expiry') |
|||
op.drop_column('item', 'qty') |
|||
# ### end Alembic commands ### |
|||
|
|||
|
|||
def downgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
op.add_column('item', sa.Column('qty', sa.INTEGER(), autoincrement=False, nullable=True)) |
|||
op.add_column('item', sa.Column('expiry', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)) |
|||
# ### end Alembic commands ### |
@ -0,0 +1,28 @@ |
|||
"""Add OpenFoodFacts ID to item |
|||
|
|||
Revision ID: b37ac6d8c8f6 |
|||
Revises: 71744666aed6 |
|||
Create Date: 2020-08-10 08:32:21.399627 |
|||
|
|||
""" |
|||
from alembic import op # noqa: E402 |
|||
import sqlalchemy as sa # noqa: E402 |
|||
|
|||
|
|||
# revision identifiers, used by Alembic. |
|||
revision = 'b37ac6d8c8f6' |
|||
down_revision = '71744666aed6' |
|||
branch_labels = None |
|||
depends_on = None |
|||
|
|||
|
|||
def upgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
op.add_column('item', sa.Column('openfoodfacts_id', sa.String(length=255), nullable=True)) |
|||
# ### end Alembic commands ### |
|||
|
|||
|
|||
def downgrade(): |
|||
# ### commands auto generated by Alembic - please adjust! ### |
|||
op.drop_column('item', 'openfoodfacts_id') |
|||
# ### end Alembic commands ### |
Loading…
Reference in new issue