сделала свою бд, нужно теперь прописывать роуты и... встречать возможные ошибки :_)

This commit is contained in:
2025-06-10 23:46:47 +04:00
parent 2f521dd674
commit 611ea95c12
31 changed files with 993 additions and 2 deletions

View File

@@ -7,8 +7,6 @@
public string? Patronymic { get; set; } = string.Empty;
public string? Email { get; set; } = string.Empty;
public string? Password { get; set; } = string.Empty;
public int? Code2FA { get; set; }
public DateTime? Date2FA { get; set; }
}
}

View File

@@ -6,6 +6,7 @@ namespace DataModels.Orders
{
public class NextCourseOrder : AbstractOrder
{
public int? NextCourse { get; set; }
public override string TemplatePath => throw new NotImplementedException();
public override void FillTemplate(DocX doc)

195
lena_backend/.gitignore vendored Normal file
View File

@@ -0,0 +1,195 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
#poetry.toml
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Abstra
# Abstra is an AI-powered process automation framework.
# Ignore directories containing user credentials, local state, and settings.
# Learn more at https://abstra.io/docs
.abstra/
# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
# .vscode/
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc
# Cursor
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
# refer to https://docs.cursor.com/context/ignore-files
.cursorignore
.cursorindexingignore

141
lena_backend/alembic.ini Normal file
View File

@@ -0,0 +1,141 @@
# A generic, single database configuration.
[alembic]
# path to migration scripts.
# this is typically a path given in POSIX (e.g. forward slashes)
# format, relative to the token %(here)s which refers to the location of this
# ini file
script_location = %(here)s/migrations
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
# Uncomment the line below if you want the files to be prepended with date and time
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
# for all available tokens
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
# sys.path path, will be prepended to sys.path if present.
# defaults to the current working directory. for multiple paths, the path separator
# is defined by "path_separator" below.
prepend_sys_path = .
# timezone to use when rendering the date within the migration file
# as well as the filename.
# If specified, requires the python>=3.9 or backports.zoneinfo library and tzdata library.
# Any required deps can installed by adding `alembic[tz]` to the pip requirements
# string value is passed to ZoneInfo()
# leave blank for localtime
# timezone =
# max length of characters to apply to the "slug" field
# truncate_slug_length = 40
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# set to 'true' to allow .pyc and .pyo files without
# a source .py file to be detected as revisions in the
# versions/ directory
# sourceless = false
# version location specification; This defaults
# to <script_location>/versions. When using multiple version
# directories, initial revisions must be specified with --version-path.
# The path separator used here should be the separator specified by "path_separator"
# below.
# version_locations = %(here)s/bar:%(here)s/bat:%(here)s/alembic/versions
# path_separator; This indicates what character is used to split lists of file
# paths, including version_locations and prepend_sys_path within configparser
# files such as alembic.ini.
# The default rendered in new alembic.ini files is "os", which uses os.pathsep
# to provide os-dependent path splitting.
#
# Note that in order to support legacy alembic.ini files, this default does NOT
# take place if path_separator is not present in alembic.ini. If this
# option is omitted entirely, fallback logic is as follows:
#
# 1. Parsing of the version_locations option falls back to using the legacy
# "version_path_separator" key, which if absent then falls back to the legacy
# behavior of splitting on spaces and/or commas.
# 2. Parsing of the prepend_sys_path option falls back to the legacy
# behavior of splitting on spaces, commas, or colons.
#
# Valid values for path_separator are:
#
# path_separator = :
# path_separator = ;
# path_separator = space
# path_separator = newline
#
# Use os.pathsep. Default configuration used for new projects.
path_separator = os
# set to 'true' to search source files recursively
# in each "version_locations" directory
# new in Alembic version 1.10
# recursive_version_locations = false
# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8
# database URL. This is consumed by the user-maintained env.py script only.
# other means of configuring database URLs may be customized within the env.py
# file.
sqlalchemy.url = postgresql://postgres:postgres@localhost/university_contingent
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples
# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks = black
# black.type = console_scripts
# black.entrypoint = black
# black.options = -l 79 REVISION_SCRIPT_FILENAME
# lint with attempts to fix using "ruff" - use the exec runner, execute a binary
# hooks = ruff
# ruff.type = exec
# ruff.executable = %(here)s/.venv/bin/ruff
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
# Logging configuration. This is also consumed by the user-maintained
# env.py script only.
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARNING
handlers = console
qualname =
[logger_sqlalchemy]
level = WARNING
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

View File

@@ -0,0 +1 @@
from app.models import Base

View File

@@ -0,0 +1,14 @@
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
import os
from dotenv import load_dotenv
load_dotenv()
DATABASE_URL = f"postgresql://{os.getenv('DB_USER')}:{os.getenv('DB_PASSWORD')}@{os.getenv('DB_HOST')}/{os.getenv('DB_NAME')}"
engine = create_engine(DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()

21
lena_backend/app/main.py Normal file
View File

@@ -0,0 +1,21 @@
from fastapi import APIRouter, FastAPI
from app.database import engine
from app.models import Base
app = FastAPI()
user_router = APIRouter(prefix="/user")
@user_router.get("/")
async def get_user():
return {"status": "ok"}
@app.on_event("startup")
async def startup():
Base.metadata.create_all(bind=engine)
@app.get("/")
async def root():
return {"message": "University API is working!"}
app.include_router(user_router)

View File

@@ -0,0 +1,16 @@
from .base import Model, Base
from .student import Student
from .group import Group
from .contingent_report import ContingentReport
from .orders.academic_leave import AcademicLeaveOrder
from .orders.add_students import AddStudentsOrder
from .orders.change_specialization import ChangeSpecializationOrder
from .orders.expulsion import ExpulsionOrder
from .orders.next_course import NextCourseOrder
from .association_tables import add_student_association, expulsion_student_association, academ_student_association, change_student_association, next_student_association
from .dean import Dean
from .enums import Status, OrderType, Reason
from .faculty import Faculty
from .learning_plan import LearningPlan
from .order import AbstractOrder
from .specialization import Specialization

View File

@@ -0,0 +1,38 @@
# models/association_tables.py
from sqlalchemy import Table, Column, Integer, ForeignKey
from app.database import Base
add_student_association = Table(
'add_student_association',
Base.metadata,
Column('order_id', Integer, ForeignKey('add_students_orders.id')),
Column('student_id', Integer, ForeignKey('students.id'))
)
academ_student_association = Table(
'academ_student_association',
Base.metadata,
Column('order_id', Integer, ForeignKey('academic_leave_orders.id')),
Column('student_id', Integer, ForeignKey('students.id'))
)
expulsion_student_association = Table(
'expulsion_student_association',
Base.metadata,
Column('order_id', Integer, ForeignKey('expulsion_orders.id')),
Column('student_id', Integer, ForeignKey('students.id'))
)
change_student_association = Table(
'change_student_association',
Base.metadata,
Column('order_id', Integer, ForeignKey('change_specialization_orders.id')),
Column('student_id', Integer, ForeignKey('students.id'))
)
next_student_association = Table(
'next_student_association',
Base.metadata,
Column('order_id', Integer, ForeignKey('next_course_orders.id')),
Column('student_id', Integer, ForeignKey('students.id'))
)

View File

@@ -0,0 +1,6 @@
from sqlalchemy import Column, Integer
from app.database import Base
class Model(Base):
__abstract__ = True
id = Column(Integer, primary_key=True, index=True)

View File

@@ -0,0 +1,17 @@
# models/contingent_report.py
from sqlalchemy import Column, Integer, ForeignKey, LargeBinary, String, DateTime
from sqlalchemy.orm import relationship
from .base import Model
from datetime import datetime
class ContingentReport(Model):
__tablename__ = "contingent_reports"
current_dean_id = Column(Integer, ForeignKey("deans.id"))
date = Column(DateTime, default=datetime.utcnow)
document = Column(LargeBinary) # Сгенерированный отчет (Word/PDF)
file_name = Column(String) # Например, "Отчет_поонтингенту_2023.docx"
file_type = Column(String) # "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
report_type = Column(String) # Тип отчета (может быть enum)
dean = relationship("Dean")

View File

@@ -0,0 +1,11 @@
# models/dean.py
from sqlalchemy import Column, Integer, ForeignKey
from sqlalchemy.orm import relationship
from .user import User
class Dean(User):
__tablename__ = "deans"
faculty_id = Column(Integer, ForeignKey("faculties.id"))
faculty = relationship("Faculty")

View File

@@ -0,0 +1,23 @@
# enums.py
from enum import Enum
class Status(str, Enum):
STUDYING = "Обучается"
ACADEMIC_LEAVE = "Академ"
EXPELLED = "Отчислен"
GRADUATED = "Выпущен"
class OrderType(str, Enum):
ADD_STUDENT = "AddStudentOrder"
EXPULSION = "ExpulsionOrder"
ACADEMIC_LEAVE = "AcademicLeaveOrder"
CHANGE_SPECIALIZATION = "ChangeSpecializationOrder"
NEXT_COURSE = "NextCourseOrder"
class Reason(str, Enum):
BY_GENERAL_CONTEST = "ByGeneralContest"
BY_PRIVILEGE = "ByPrivilege"
BY_CHOICE = "ByChoice"
BY_LEARNING_FAILURE = "ByLearningFailure"
BY_MEDICAL = "ByMedical"
BY_FAMILY = "ByFamily"

View File

@@ -0,0 +1,11 @@
# models/faculty.py
from sqlalchemy import Column, String
from sqlalchemy.orm import relationship
from .base import Model
class Faculty(Model):
__tablename__ = "faculties"
name = Column(String)
specializations = relationship("Specialization", back_populates="faculty")

View File

@@ -0,0 +1,17 @@
from sqlalchemy import Column, Integer, ForeignKey, String
from sqlalchemy.orm import relationship
from .base import Base
class Group(Base):
__tablename__ = 'groups'
id = Column(Integer, primary_key=True, index=True)
name = Column(String)
number = Column(Integer)
course = Column(Integer)
max_student_count = Column(Integer, default=30)
specialization_id = Column(Integer, ForeignKey('specializations.id'))
count_students = Column(Integer, default=0)
specialization = relationship("Specialization", back_populates="groups")
students = relationship("Student", back_populates="group")

View File

@@ -0,0 +1,14 @@
# models/learning_plan.py
from sqlalchemy import Column, Integer, ForeignKey, LargeBinary, String
from sqlalchemy.orm import relationship
from .base import Model
class LearningPlan(Model):
__tablename__ = "learning_plans"
specialization_id = Column(Integer, ForeignKey("specializations.id"))
document = Column(LargeBinary) # PDF/docx файл учебного плана
file_name = Column(String) # Оригинальное имя файла
file_type = Column(String) # MIME-тип (например, "application/pdf")
specialization = relationship("Specialization", back_populates="learning_plans")

View File

@@ -0,0 +1,19 @@
# models/order.py
from sqlalchemy import Column, Integer, ForeignKey, DateTime, Enum, LargeBinary
from sqlalchemy.orm import relationship
from .base import Model
from .enums import OrderType, Reason
from datetime import datetime
class AbstractOrder(Model):
__abstract__ = True
order_type = Column(Enum(OrderType))
reason = Column(Enum(Reason))
number = Column(Integer)
current_dean_id = Column(Integer, ForeignKey("deans.id"))
date = Column(DateTime, default=datetime.now)
document = Column(LargeBinary)
# students = relationship("Student", secondary="order_student_association")
# dean = relationship("Dean")

View File

@@ -0,0 +1,13 @@
# models/orders/academic_leave.py
from sqlalchemy import Column, DateTime
from ..order import AbstractOrder
from sqlalchemy.orm import relationship
class AcademicLeaveOrder(AbstractOrder):
__tablename__ = "academic_leave_orders"
date_start = Column(DateTime)
date_end = Column(DateTime)
students = relationship("Student", secondary="academ_student_association")
dean = relationship("Dean")

View File

@@ -0,0 +1,10 @@
# models/orders/add_students.py
from ..order import AbstractOrder
from sqlalchemy.orm import relationship
class AddStudentsOrder(AbstractOrder):
__tablename__ = "add_students_orders"
students = relationship("Student", secondary="add_student_association")
dean = relationship("Dean")

View File

@@ -0,0 +1,13 @@
# models/orders/change_specialization.py
from sqlalchemy import Column, Integer, ForeignKey
from ..order import AbstractOrder
from sqlalchemy.orm import relationship
class ChangeSpecializationOrder(AbstractOrder):
__tablename__ = "change_specialization_orders"
new_spec_id = Column(Integer, ForeignKey("specializations.id"))
new_specialization = relationship("Specialization")
students = relationship("Student", secondary="change_student_association")
dean = relationship("Dean")

View File

@@ -0,0 +1,10 @@
# models/orders/expulsion.py
from ..order import AbstractOrder
from sqlalchemy.orm import relationship
class ExpulsionOrder(AbstractOrder):
__tablename__ = "expulsion_orders"
students = relationship("Student", secondary="expulsion_student_association")
dean = relationship("Dean")

View File

@@ -0,0 +1,13 @@
# models/orders/next_course.py
from sqlalchemy import Column, Integer
from ..order import AbstractOrder
from sqlalchemy.orm import relationship
class NextCourseOrder(AbstractOrder):
__tablename__ = "next_course_orders"
# Можно добавить поле для нового курса, если нужно
new_course = Column(Integer)
students = relationship("Student", secondary="next_student_association")
dean = relationship("Dean")

View File

@@ -0,0 +1,15 @@
# models/specialization.py
from sqlalchemy import Column, String, Integer, ForeignKey
from sqlalchemy.orm import relationship
from .base import Model
class Specialization(Model):
__tablename__ = "specializations"
name = Column(String)
code = Column(String)
faculty_id = Column(Integer, ForeignKey("faculties.id"))
faculty = relationship("Faculty", back_populates="specializations")
groups = relationship("Group", back_populates="specialization")
learning_plans = relationship("LearningPlan", back_populates="specialization")

View File

@@ -0,0 +1,15 @@
# models/student.py
from sqlalchemy import Column, Integer, ForeignKey, Enum
from sqlalchemy.orm import relationship
from .user import User
from .enums import Status
class Student(User):
__tablename__ = "students"
specialization_id = Column(Integer, ForeignKey("specializations.id"))
group_id = Column(Integer, ForeignKey("groups.id"))
status = Column(Enum(Status))
group = relationship("Group", back_populates="students")
specialization = relationship("Specialization")

View File

@@ -0,0 +1,13 @@
# models/user.py
from sqlalchemy import Column, String, ForeignKey
from sqlalchemy.orm import declared_attr
from .base import Model
class User(Model):
__abstract__ = True
last_name = Column(String)
first_name = Column(String)
patronymic = Column(String)
email = Column(String, unique=True, index=True)
password = Column(String)

View File

@@ -0,0 +1 @@
Generic single-database configuration.

View File

@@ -0,0 +1,82 @@
from logging.config import fileConfig
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
from app.models import Model, Student
from app.database import Base
target_metadata = Base.metadata
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
if config.config_file_name is not None:
fileConfig(config.config_file_name)
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.
def run_migrations_offline() -> None:
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.
"""
url = config.get_main_option("sqlalchemy.url")
context.configure(
url=url,
target_metadata=target_metadata,
literal_binds=True,
dialect_opts={"paramstyle": "named"},
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online() -> None:
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section, {}),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)
with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

View File

@@ -0,0 +1,28 @@
"""${message}
Revision ID: ${up_revision}
Revises: ${down_revision | comma,n}
Create Date: ${create_date}
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
${imports if imports else ""}
# revision identifiers, used by Alembic.
revision: str = ${repr(up_revision)}
down_revision: Union[str, None] = ${repr(down_revision)}
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
def upgrade() -> None:
"""Upgrade schema."""
${upgrades if upgrades else "pass"}
def downgrade() -> None:
"""Downgrade schema."""
${downgrades if downgrades else "pass"}

View File

@@ -0,0 +1,234 @@
"""Initial migration
Revision ID: bf949a0ed375
Revises:
Create Date: 2025-06-10 23:44:56.541030
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'bf949a0ed375'
down_revision: Union[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('faculties',
sa.Column('name', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_faculties_id'), 'faculties', ['id'], unique=False)
op.create_table('deans',
sa.Column('faculty_id', sa.Integer(), nullable=True),
sa.Column('last_name', sa.String(), nullable=True),
sa.Column('first_name', sa.String(), nullable=True),
sa.Column('patronymic', sa.String(), nullable=True),
sa.Column('email', sa.String(), nullable=True),
sa.Column('password', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['faculty_id'], ['faculties.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_deans_email'), 'deans', ['email'], unique=True)
op.create_index(op.f('ix_deans_id'), 'deans', ['id'], unique=False)
op.create_table('specializations',
sa.Column('name', sa.String(), nullable=True),
sa.Column('code', sa.String(), nullable=True),
sa.Column('faculty_id', sa.Integer(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['faculty_id'], ['faculties.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_specializations_id'), 'specializations', ['id'], unique=False)
op.create_table('academic_leave_orders',
sa.Column('date_start', sa.DateTime(), nullable=True),
sa.Column('date_end', sa.DateTime(), nullable=True),
sa.Column('order_type', sa.Enum('ADD_STUDENT', 'EXPULSION', 'ACADEMIC_LEAVE', 'CHANGE_SPECIALIZATION', 'NEXT_COURSE', name='ordertype'), nullable=True),
sa.Column('reason', sa.Enum('BY_GENERAL_CONTEST', 'BY_PRIVILEGE', 'BY_CHOICE', 'BY_LEARNING_FAILURE', 'BY_MEDICAL', 'BY_FAMILY', name='reason'), nullable=True),
sa.Column('number', sa.Integer(), nullable=True),
sa.Column('current_dean_id', sa.Integer(), nullable=True),
sa.Column('date', sa.DateTime(), nullable=True),
sa.Column('document', sa.LargeBinary(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['current_dean_id'], ['deans.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_academic_leave_orders_id'), 'academic_leave_orders', ['id'], unique=False)
op.create_table('add_students_orders',
sa.Column('order_type', sa.Enum('ADD_STUDENT', 'EXPULSION', 'ACADEMIC_LEAVE', 'CHANGE_SPECIALIZATION', 'NEXT_COURSE', name='ordertype'), nullable=True),
sa.Column('reason', sa.Enum('BY_GENERAL_CONTEST', 'BY_PRIVILEGE', 'BY_CHOICE', 'BY_LEARNING_FAILURE', 'BY_MEDICAL', 'BY_FAMILY', name='reason'), nullable=True),
sa.Column('number', sa.Integer(), nullable=True),
sa.Column('current_dean_id', sa.Integer(), nullable=True),
sa.Column('date', sa.DateTime(), nullable=True),
sa.Column('document', sa.LargeBinary(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['current_dean_id'], ['deans.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_add_students_orders_id'), 'add_students_orders', ['id'], unique=False)
op.create_table('change_specialization_orders',
sa.Column('new_spec_id', sa.Integer(), nullable=True),
sa.Column('order_type', sa.Enum('ADD_STUDENT', 'EXPULSION', 'ACADEMIC_LEAVE', 'CHANGE_SPECIALIZATION', 'NEXT_COURSE', name='ordertype'), nullable=True),
sa.Column('reason', sa.Enum('BY_GENERAL_CONTEST', 'BY_PRIVILEGE', 'BY_CHOICE', 'BY_LEARNING_FAILURE', 'BY_MEDICAL', 'BY_FAMILY', name='reason'), nullable=True),
sa.Column('number', sa.Integer(), nullable=True),
sa.Column('current_dean_id', sa.Integer(), nullable=True),
sa.Column('date', sa.DateTime(), nullable=True),
sa.Column('document', sa.LargeBinary(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['current_dean_id'], ['deans.id'], ),
sa.ForeignKeyConstraint(['new_spec_id'], ['specializations.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_change_specialization_orders_id'), 'change_specialization_orders', ['id'], unique=False)
op.create_table('contingent_reports',
sa.Column('current_dean_id', sa.Integer(), nullable=True),
sa.Column('date', sa.DateTime(), nullable=True),
sa.Column('document', sa.LargeBinary(), nullable=True),
sa.Column('file_name', sa.String(), nullable=True),
sa.Column('file_type', sa.String(), nullable=True),
sa.Column('report_type', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['current_dean_id'], ['deans.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_contingent_reports_id'), 'contingent_reports', ['id'], unique=False)
op.create_table('expulsion_orders',
sa.Column('order_type', sa.Enum('ADD_STUDENT', 'EXPULSION', 'ACADEMIC_LEAVE', 'CHANGE_SPECIALIZATION', 'NEXT_COURSE', name='ordertype'), nullable=True),
sa.Column('reason', sa.Enum('BY_GENERAL_CONTEST', 'BY_PRIVILEGE', 'BY_CHOICE', 'BY_LEARNING_FAILURE', 'BY_MEDICAL', 'BY_FAMILY', name='reason'), nullable=True),
sa.Column('number', sa.Integer(), nullable=True),
sa.Column('current_dean_id', sa.Integer(), nullable=True),
sa.Column('date', sa.DateTime(), nullable=True),
sa.Column('document', sa.LargeBinary(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['current_dean_id'], ['deans.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_expulsion_orders_id'), 'expulsion_orders', ['id'], unique=False)
op.create_table('groups',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('number', sa.Integer(), nullable=True),
sa.Column('course', sa.Integer(), nullable=True),
sa.Column('max_student_count', sa.Integer(), nullable=True),
sa.Column('specialization_id', sa.Integer(), nullable=True),
sa.Column('count_students', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['specialization_id'], ['specializations.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_groups_id'), 'groups', ['id'], unique=False)
op.create_table('learning_plans',
sa.Column('specialization_id', sa.Integer(), nullable=True),
sa.Column('document', sa.LargeBinary(), nullable=True),
sa.Column('file_name', sa.String(), nullable=True),
sa.Column('file_type', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['specialization_id'], ['specializations.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_learning_plans_id'), 'learning_plans', ['id'], unique=False)
op.create_table('next_course_orders',
sa.Column('new_course', sa.Integer(), nullable=True),
sa.Column('order_type', sa.Enum('ADD_STUDENT', 'EXPULSION', 'ACADEMIC_LEAVE', 'CHANGE_SPECIALIZATION', 'NEXT_COURSE', name='ordertype'), nullable=True),
sa.Column('reason', sa.Enum('BY_GENERAL_CONTEST', 'BY_PRIVILEGE', 'BY_CHOICE', 'BY_LEARNING_FAILURE', 'BY_MEDICAL', 'BY_FAMILY', name='reason'), nullable=True),
sa.Column('number', sa.Integer(), nullable=True),
sa.Column('current_dean_id', sa.Integer(), nullable=True),
sa.Column('date', sa.DateTime(), nullable=True),
sa.Column('document', sa.LargeBinary(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['current_dean_id'], ['deans.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_next_course_orders_id'), 'next_course_orders', ['id'], unique=False)
op.create_table('students',
sa.Column('specialization_id', sa.Integer(), nullable=True),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('status', sa.Enum('STUDYING', 'ACADEMIC_LEAVE', 'EXPELLED', 'GRADUATED', name='status'), nullable=True),
sa.Column('last_name', sa.String(), nullable=True),
sa.Column('first_name', sa.String(), nullable=True),
sa.Column('patronymic', sa.String(), nullable=True),
sa.Column('email', sa.String(), nullable=True),
sa.Column('password', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['group_id'], ['groups.id'], ),
sa.ForeignKeyConstraint(['specialization_id'], ['specializations.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_students_email'), 'students', ['email'], unique=True)
op.create_index(op.f('ix_students_id'), 'students', ['id'], unique=False)
op.create_table('academ_student_association',
sa.Column('order_id', sa.Integer(), nullable=True),
sa.Column('student_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['order_id'], ['academic_leave_orders.id'], ),
sa.ForeignKeyConstraint(['student_id'], ['students.id'], )
)
op.create_table('add_student_association',
sa.Column('order_id', sa.Integer(), nullable=True),
sa.Column('student_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['order_id'], ['add_students_orders.id'], ),
sa.ForeignKeyConstraint(['student_id'], ['students.id'], )
)
op.create_table('change_student_association',
sa.Column('order_id', sa.Integer(), nullable=True),
sa.Column('student_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['order_id'], ['change_specialization_orders.id'], ),
sa.ForeignKeyConstraint(['student_id'], ['students.id'], )
)
op.create_table('expulsion_student_association',
sa.Column('order_id', sa.Integer(), nullable=True),
sa.Column('student_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['order_id'], ['expulsion_orders.id'], ),
sa.ForeignKeyConstraint(['student_id'], ['students.id'], )
)
op.create_table('next_student_association',
sa.Column('order_id', sa.Integer(), nullable=True),
sa.Column('student_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['order_id'], ['next_course_orders.id'], ),
sa.ForeignKeyConstraint(['student_id'], ['students.id'], )
)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('next_student_association')
op.drop_table('expulsion_student_association')
op.drop_table('change_student_association')
op.drop_table('add_student_association')
op.drop_table('academ_student_association')
op.drop_index(op.f('ix_students_id'), table_name='students')
op.drop_index(op.f('ix_students_email'), table_name='students')
op.drop_table('students')
op.drop_index(op.f('ix_next_course_orders_id'), table_name='next_course_orders')
op.drop_table('next_course_orders')
op.drop_index(op.f('ix_learning_plans_id'), table_name='learning_plans')
op.drop_table('learning_plans')
op.drop_index(op.f('ix_groups_id'), table_name='groups')
op.drop_table('groups')
op.drop_index(op.f('ix_expulsion_orders_id'), table_name='expulsion_orders')
op.drop_table('expulsion_orders')
op.drop_index(op.f('ix_contingent_reports_id'), table_name='contingent_reports')
op.drop_table('contingent_reports')
op.drop_index(op.f('ix_change_specialization_orders_id'), table_name='change_specialization_orders')
op.drop_table('change_specialization_orders')
op.drop_index(op.f('ix_add_students_orders_id'), table_name='add_students_orders')
op.drop_table('add_students_orders')
op.drop_index(op.f('ix_academic_leave_orders_id'), table_name='academic_leave_orders')
op.drop_table('academic_leave_orders')
op.drop_index(op.f('ix_specializations_id'), table_name='specializations')
op.drop_table('specializations')
op.drop_index(op.f('ix_deans_id'), table_name='deans')
op.drop_index(op.f('ix_deans_email'), table_name='deans')
op.drop_table('deans')
op.drop_index(op.f('ix_faculties_id'), table_name='faculties')
op.drop_table('faculties')
# ### end Alembic commands ###

BIN
lena_backend/reqs.txt Normal file

Binary file not shown.

View File

@@ -22,3 +22,4 @@ logs
.env
.env.*
!.env.example