fix alembic first migration
Some checks failed
Deploy Amap / deploy (push) Failing after 5s

This commit is contained in:
2026-02-20 00:10:36 +01:00
parent f6101a251a
commit a16c940452
8 changed files with 163 additions and 164 deletions

View File

@@ -1,155 +0,0 @@
"""Initial repository
Revision ID: 370137544ee6
Revises:
Create Date: 2026-02-19 22:55:19.804879
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
import sqlmodel.sql.sqltypes
# revision identifiers, used by Alembic.
revision: str = '370137544ee6'
down_revision: Union[str, Sequence[str], None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('template')
op.drop_table('user')
op.drop_table('form')
op.drop_table('usercontracttypelink')
op.drop_table('shipment')
op.drop_table('cheque')
op.drop_table('productor')
op.drop_table('paymentmethod')
op.drop_table('contract')
op.drop_table('contractproduct')
op.drop_table('contracttype')
op.drop_table('product')
op.drop_table('shipmentproductlink')
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('shipmentproductlink',
sa.Column('shipment_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('product_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['product_id'], ['product.id'], name=op.f('shipmentproductlink_product_id_fkey')),
sa.ForeignKeyConstraint(['shipment_id'], ['shipment.id'], name=op.f('shipmentproductlink_shipment_id_fkey')),
sa.PrimaryKeyConstraint('shipment_id', 'product_id', name=op.f('shipmentproductlink_pkey'))
)
op.create_table('product',
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('unit', postgresql.ENUM('GRAMS', 'KILO', 'PIECE', name='unit'), autoincrement=False, nullable=False),
sa.Column('price', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True),
sa.Column('price_kg', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True),
sa.Column('quantity', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True),
sa.Column('quantity_unit', sa.VARCHAR(), autoincrement=False, nullable=True),
sa.Column('type', postgresql.ENUM('OCCASIONAL', 'RECCURENT', name='producttype'), autoincrement=False, nullable=False),
sa.Column('productor_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.ForeignKeyConstraint(['productor_id'], ['productor.id'], name=op.f('product_productor_id_fkey')),
sa.PrimaryKeyConstraint('id', name=op.f('product_pkey'))
)
op.create_table('contracttype',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('contracttype_pkey'))
)
op.create_table('contractproduct',
sa.Column('product_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('shipment_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('quantity', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('contract_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['contract_id'], ['contract.id'], name=op.f('contractproduct_contract_id_fkey'), ondelete='CASCADE'),
sa.ForeignKeyConstraint(['product_id'], ['product.id'], name=op.f('contractproduct_product_id_fkey'), ondelete='CASCADE'),
sa.ForeignKeyConstraint(['shipment_id'], ['shipment.id'], name=op.f('contractproduct_shipment_id_fkey'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('contractproduct_pkey'))
)
op.create_table('contract',
sa.Column('firstname', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('lastname', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('email', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('phone', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('payment_method', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('cheque_quantity', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('form_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('file', postgresql.BYTEA(), autoincrement=False, nullable=True),
sa.Column('total_price', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True),
sa.ForeignKeyConstraint(['form_id'], ['form.id'], name=op.f('contract_form_id_fkey'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('contract_pkey'))
)
op.create_table('paymentmethod',
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('details', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('productor_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['productor_id'], ['productor.id'], name=op.f('paymentmethod_productor_id_fkey'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('paymentmethod_pkey'))
)
op.create_table('productor',
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('address', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('type', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('productor_pkey'))
)
op.create_table('cheque',
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('value', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('contract_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['contract_id'], ['contract.id'], name=op.f('cheque_contract_id_fkey'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('cheque_pkey'))
)
op.create_table('shipment',
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('date', sa.DATE(), autoincrement=False, nullable=False),
sa.Column('form_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.ForeignKeyConstraint(['form_id'], ['form.id'], name=op.f('shipment_form_id_fkey'), ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id', name=op.f('shipment_pkey'))
)
op.create_table('usercontracttypelink',
sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('contract_type_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['contract_type_id'], ['contracttype.id'], name=op.f('usercontracttypelink_contract_type_id_fkey')),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], name=op.f('usercontracttypelink_user_id_fkey')),
sa.PrimaryKeyConstraint('user_id', 'contract_type_id', name=op.f('usercontracttypelink_pkey'))
)
op.create_table('form',
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('productor_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('referer_id', sa.INTEGER(), autoincrement=False, nullable=True),
sa.Column('season', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('start', sa.DATE(), autoincrement=False, nullable=False),
sa.Column('end', sa.DATE(), autoincrement=False, nullable=False),
sa.Column('minimum_shipment_value', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=True),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.ForeignKeyConstraint(['productor_id'], ['productor.id'], name=op.f('form_productor_id_fkey')),
sa.ForeignKeyConstraint(['referer_id'], ['user.id'], name=op.f('form_referer_id_fkey')),
sa.PrimaryKeyConstraint('id', name=op.f('form_pkey'))
)
op.create_table('user',
sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('email', sa.VARCHAR(), autoincrement=False, nullable=False),
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('user_pkey'))
)
op.create_table('template',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint('id', name=op.f('template_pkey'))
)
# ### end Alembic commands ###

View File

@@ -0,0 +1,155 @@
"""Initial repository
Revision ID: c0b1073a8394
Revises:
Create Date: 2026-02-20 00:09:35.920486
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes
# revision identifiers, used by Alembic.
revision: str = 'c0b1073a8394'
down_revision: Union[str, Sequence[str], None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('contracttype',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('productor',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('address', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('type', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('template',
sa.Column('id', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('form',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('productor_id', sa.Integer(), nullable=True),
sa.Column('referer_id', sa.Integer(), nullable=True),
sa.Column('season', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('start', sa.Date(), nullable=False),
sa.Column('end', sa.Date(), nullable=False),
sa.Column('minimum_shipment_value', sa.Float(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['productor_id'], ['productor.id'], ),
sa.ForeignKeyConstraint(['referer_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('paymentmethod',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('details', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('productor_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['productor_id'], ['productor.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('product',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('unit', sa.Enum('GRAMS', 'KILO', 'PIECE', name='unit'), nullable=False),
sa.Column('price', sa.Float(), nullable=True),
sa.Column('price_kg', sa.Float(), nullable=True),
sa.Column('quantity', sa.Float(), nullable=True),
sa.Column('quantity_unit', sqlmodel.sql.sqltypes.AutoString(), nullable=True),
sa.Column('type', sa.Enum('OCCASIONAL', 'RECCURENT', name='producttype'), nullable=False),
sa.Column('productor_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['productor_id'], ['productor.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('usercontracttypelink',
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('contract_type_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['contract_type_id'], ['contracttype.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('user_id', 'contract_type_id')
)
op.create_table('contract',
sa.Column('firstname', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('lastname', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('email', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('phone', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('payment_method', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('cheque_quantity', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('form_id', sa.Integer(), nullable=False),
sa.Column('file', sa.LargeBinary(), nullable=True),
sa.Column('total_price', sa.Float(), nullable=True),
sa.ForeignKeyConstraint(['form_id'], ['form.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('shipment',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('date', sa.Date(), nullable=False),
sa.Column('form_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['form_id'], ['form.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('cheque',
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('value', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('contract_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['contract_id'], ['contract.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('contractproduct',
sa.Column('product_id', sa.Integer(), nullable=False),
sa.Column('shipment_id', sa.Integer(), nullable=True),
sa.Column('quantity', sa.Float(), nullable=False),
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('contract_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['contract_id'], ['contract.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['product_id'], ['product.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['shipment_id'], ['shipment.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('shipmentproductlink',
sa.Column('shipment_id', sa.Integer(), nullable=False),
sa.Column('product_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['product_id'], ['product.id'], ),
sa.ForeignKeyConstraint(['shipment_id'], ['shipment.id'], ),
sa.PrimaryKeyConstraint('shipment_id', 'product_id')
)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('shipmentproductlink')
op.drop_table('contractproduct')
op.drop_table('cheque')
op.drop_table('shipment')
op.drop_table('contract')
op.drop_table('usercontracttypelink')
op.drop_table('product')
op.drop_table('paymentmethod')
op.drop_table('form')
op.drop_table('user')
op.drop_table('template')
op.drop_table('productor')
op.drop_table('contracttype')
# ### end Alembic commands ###