34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
from sqlalchemy import create_engine, Column, Integer, Integer, String, Text
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
DATABASE_URL = "sqlite:///./app.db"
|
|
engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
Base = declarative_base()
|
|
|
|
class Product(Base):
|
|
__tablename__ = "products"
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
product_id = Column(Integer, nullable=False)
|
|
name = Column(String(255), nullable=False)
|
|
description = Column(Text)
|
|
category = Column(String(50), nullable=False)
|
|
|
|
class StorageLocation(Base):
|
|
__tablename__ = "storage_locations"
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
location_id = Column(Integer, nullable=False)
|
|
name = Column(String(255), nullable=False)
|
|
capacity = Column(Integer, nullable=False, default=0)
|
|
|
|
class Transfer(Base):
|
|
__tablename__ = "transfers"
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
transfer_id = Column(Integer, nullable=False)
|
|
product_id = Column(Integer, nullable=False)
|
|
from_location_id = Column(Integer, nullable=False)
|
|
to_location_id = Column(Integer, nullable=False)
|
|
quantity = Column(Integer, nullable=False, default=0)
|
|
|
|
Base.metadata.create_all(bind=engine) |