mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Добавления тестов бекенда1
This commit is contained in:
14
backend/app/init_db.py
Normal file
14
backend/app/init_db.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
"""Database initialization"""
|
||||||
|
from .database import Base, engine
|
||||||
|
from .models.employee import Employee
|
||||||
|
from .models.request import Request
|
||||||
|
|
||||||
|
def init_db():
|
||||||
|
"""Initialize database"""
|
||||||
|
# Удаляем все существующие таблицы
|
||||||
|
Base.metadata.drop_all(bind=engine)
|
||||||
|
# Создаем таблицы заново
|
||||||
|
Base.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
init_db()
|
@@ -1,5 +1,5 @@
|
|||||||
"""Request model"""
|
"""Request model"""
|
||||||
from sqlalchemy import Column, Integer, String, Enum, ForeignKey, DateTime
|
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
||||||
from sqlalchemy.sql import func
|
from sqlalchemy.sql import func
|
||||||
from sqlalchemy.orm import relationship
|
from sqlalchemy.orm import relationship
|
||||||
from enum import Enum as PyEnum
|
from enum import Enum as PyEnum
|
||||||
@@ -9,7 +9,7 @@ class RequestStatus(str, PyEnum):
|
|||||||
NEW = "new"
|
NEW = "new"
|
||||||
IN_PROGRESS = "in_progress"
|
IN_PROGRESS = "in_progress"
|
||||||
COMPLETED = "completed"
|
COMPLETED = "completed"
|
||||||
CANCELLED = "cancelled"
|
REJECTED = "rejected"
|
||||||
|
|
||||||
class RequestPriority(str, PyEnum):
|
class RequestPriority(str, PyEnum):
|
||||||
LOW = "low"
|
LOW = "low"
|
||||||
@@ -18,7 +18,6 @@ class RequestPriority(str, PyEnum):
|
|||||||
|
|
||||||
class Request(Base):
|
class Request(Base):
|
||||||
__tablename__ = "requests"
|
__tablename__ = "requests"
|
||||||
__table_args__ = {'extend_existing': True}
|
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True, index=True)
|
id = Column(Integer, primary_key=True, index=True)
|
||||||
title = Column(String, nullable=False)
|
title = Column(String, nullable=False)
|
||||||
|
Reference in New Issue
Block a user