mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
base3
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
"""create tokens table
|
||||
|
||||
Revision ID: create_tokens_table
|
||||
Revises:
|
||||
Create Date: 2024-01-02 22:30:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'create_tokens_table'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
'tokens',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('access_token', sa.String(), nullable=False),
|
||||
sa.Column('employee_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_tokens_access_token'), 'tokens', ['access_token'], unique=True)
|
||||
op.create_index(op.f('ix_tokens_id'), 'tokens', ['id'], unique=False)
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(op.f('ix_tokens_id'), table_name='tokens')
|
||||
op.drop_index(op.f('ix_tokens_access_token'), table_name='tokens')
|
||||
op.drop_table('tokens')
|
@@ -1,35 +0,0 @@
|
||||
"""create tokens table
|
||||
|
||||
Revision ID: create_tokens_table_new
|
||||
Revises: initial_migration
|
||||
Create Date: 2024-01-03 17:45:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'create_tokens_table_new'
|
||||
down_revision = 'initial_migration'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade() -> None:
|
||||
# Создаем таблицу tokens
|
||||
op.create_table(
|
||||
'tokens',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('access_token', sa.String(), nullable=False),
|
||||
sa.Column('employee_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_tokens_access_token'), 'tokens', ['access_token'], unique=True)
|
||||
op.create_index(op.f('ix_tokens_id'), 'tokens', ['id'], unique=False)
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(op.f('ix_tokens_id'), table_name='tokens')
|
||||
op.drop_index(op.f('ix_tokens_access_token'), table_name='tokens')
|
||||
op.drop_table('tokens')
|
@@ -1,87 +0,0 @@
|
||||
"""initial migration
|
||||
|
||||
Revision ID: initial_migration
|
||||
Revises:
|
||||
Create Date: 2024-01-03 11:00:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'initial_migration'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade() -> None:
|
||||
# Создаем enum типы
|
||||
request_status = postgresql.ENUM('new', 'in_progress', 'completed', 'rejected', name='requeststatus')
|
||||
request_status.create(op.get_bind())
|
||||
|
||||
request_priority = postgresql.ENUM('low', 'medium', 'high', name='requestpriority')
|
||||
request_priority.create(op.get_bind())
|
||||
|
||||
# Создаем таблицу employees
|
||||
op.create_table(
|
||||
'employees',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('first_name', sa.String(), nullable=False),
|
||||
sa.Column('last_name', sa.String(), nullable=False),
|
||||
sa.Column('department', sa.String(), nullable=False),
|
||||
sa.Column('office', sa.String(), nullable=False),
|
||||
sa.Column('hashed_password', sa.String(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
# Создаем таблицу requests
|
||||
op.create_table(
|
||||
'requests',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('title', sa.String(), nullable=False),
|
||||
sa.Column('description', sa.String(), nullable=False),
|
||||
sa.Column('status', sa.Enum('new', 'in_progress', 'completed', 'rejected', name='requeststatus'), nullable=False),
|
||||
sa.Column('priority', sa.Enum('low', 'medium', 'high', name='requestpriority'), nullable=False),
|
||||
sa.Column('employee_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
# Создаем таблицу tokens
|
||||
op.create_table(
|
||||
'tokens',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('access_token', sa.String(), nullable=False),
|
||||
sa.Column('employee_id', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
||||
sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False),
|
||||
sa.ForeignKeyConstraint(['employee_id'], ['employees.id'], ondelete='CASCADE'),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
# Создаем индексы
|
||||
op.create_index(op.f('ix_employees_id'), 'employees', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_employees_last_name'), 'employees', ['last_name'], unique=False)
|
||||
op.create_index(op.f('ix_requests_id'), 'requests', ['id'], unique=False)
|
||||
op.create_index(op.f('ix_tokens_access_token'), 'tokens', ['access_token'], unique=True)
|
||||
op.create_index(op.f('ix_tokens_id'), 'tokens', ['id'], unique=False)
|
||||
|
||||
def downgrade() -> None:
|
||||
# Удаляем индексы
|
||||
op.drop_index(op.f('ix_tokens_id'), table_name='tokens')
|
||||
op.drop_index(op.f('ix_tokens_access_token'), table_name='tokens')
|
||||
op.drop_index(op.f('ix_requests_id'), table_name='requests')
|
||||
op.drop_index(op.f('ix_employees_last_name'), table_name='employees')
|
||||
op.drop_index(op.f('ix_employees_id'), table_name='employees')
|
||||
|
||||
# Удаляем таблицы
|
||||
op.drop_table('tokens')
|
||||
op.drop_table('requests')
|
||||
op.drop_table('employees')
|
||||
|
||||
# Удаляем enum типы
|
||||
op.execute('DROP TYPE requeststatus')
|
||||
op.execute('DROP TYPE requestpriority')
|
@@ -1,8 +1,8 @@
|
||||
"""single migration
|
||||
"""initial schema
|
||||
|
||||
Revision ID: single_migration
|
||||
Revision ID: initial_schema
|
||||
Revises:
|
||||
Create Date: 2024-01-03 20:30:00.000000
|
||||
Create Date: 2024-01-03 20:45:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
@@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'single_migration'
|
||||
revision = 'initial_schema'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
@@ -1,21 +0,0 @@
|
||||
"""merge heads
|
||||
|
||||
Revision ID: merge_heads
|
||||
Revises: initial_migration, create_tokens_table
|
||||
Create Date: 2024-01-03 10:52:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'merge_heads'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = ('initial_migration', 'create_tokens_table')
|
||||
|
||||
def upgrade():
|
||||
pass
|
||||
|
||||
def downgrade():
|
||||
pass
|
@@ -1,21 +0,0 @@
|
||||
"""merge heads
|
||||
|
||||
Revision ID: merge_heads_new
|
||||
Revises: initial_migration, create_tokens_table_new
|
||||
Create Date: 2024-01-03 20:25:00.000000
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'merge_heads_new'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = ['initial_migration', 'create_tokens_table_new']
|
||||
|
||||
def upgrade() -> None:
|
||||
pass
|
||||
|
||||
def downgrade() -> None:
|
||||
pass
|
Reference in New Issue
Block a user