"""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 ###