增加資料庫連線到MySQL

This commit is contained in:
2025-10-28 21:38:53 +08:00
parent f690604c4a
commit e441a328ab
12 changed files with 1562 additions and 17 deletions

1
migrations/README Normal file
View File

@@ -0,0 +1 @@
Single-database configuration for Flask.

50
migrations/alembic.ini Normal file
View File

@@ -0,0 +1,50 @@
# A generic, single database configuration.
[alembic]
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic,flask_migrate
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[logger_flask_migrate]
level = INFO
handlers =
qualname = flask_migrate
[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

113
migrations/env.py Normal file
View File

@@ -0,0 +1,113 @@
import logging
from logging.config import fileConfig
from flask import current_app
from alembic import context
# 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.
fileConfig(config.config_file_name)
logger = logging.getLogger('alembic.env')
def get_engine():
try:
# this works with Flask-SQLAlchemy<3 and Alchemical
return current_app.extensions['migrate'].db.get_engine()
except (TypeError, AttributeError):
# this works with Flask-SQLAlchemy>=3
return current_app.extensions['migrate'].db.engine
def get_engine_url():
try:
return get_engine().url.render_as_string(hide_password=False).replace(
'%', '%%')
except AttributeError:
return str(get_engine().url).replace('%', '%%')
# add your model's MetaData object here
# for 'autogenerate' support
# from myapp import mymodel
# target_metadata = mymodel.Base.metadata
config.set_main_option('sqlalchemy.url', get_engine_url())
target_db = current_app.extensions['migrate'].db
# 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 get_metadata():
if hasattr(target_db, 'metadatas'):
return target_db.metadatas[None]
return target_db.metadata
def run_migrations_offline():
"""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=get_metadata(), literal_binds=True
)
with context.begin_transaction():
context.run_migrations()
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
# this callback is used to prevent an auto-migration from being generated
# when there are no changes to the schema
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
if getattr(config.cmd_opts, 'autogenerate', False):
script = directives[0]
if script.upgrade_ops.is_empty():
directives[:] = []
logger.info('No changes in schema detected.')
conf_args = current_app.extensions['migrate'].configure_args
if conf_args.get("process_revision_directives") is None:
conf_args["process_revision_directives"] = process_revision_directives
connectable = get_engine()
with connectable.connect() as connection:
context.configure(
connection=connection,
target_metadata=get_metadata(),
**conf_args
)
with context.begin_transaction():
context.run_migrations()
if context.is_offline_mode():
run_migrations_offline()
else:
run_migrations_online()

24
migrations/script.py.mako Normal file
View File

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

View File

@@ -0,0 +1,387 @@
"""Initial migration from SQLite to MySQL
Revision ID: b4d5a641842e
Revises:
Create Date: 2025-10-28 19:24:28.282109
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
# revision identifiers, used by Alembic.
revision = 'b4d5a641842e'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('capability',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=100), nullable=False),
sa.Column('l1_description', sa.Text(), nullable=True),
sa.Column('l2_description', sa.Text(), nullable=True),
sa.Column('l3_description', sa.Text(), nullable=True),
sa.Column('l4_description', sa.Text(), nullable=True),
sa.Column('l5_description', sa.Text(), nullable=True),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('employee_point',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('employee_name', sa.String(length=100), nullable=False),
sa.Column('department', sa.String(length=50), nullable=False),
sa.Column('position', sa.String(length=50), nullable=False),
sa.Column('total_points', sa.Integer(), nullable=True),
sa.Column('monthly_points', sa.Integer(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('star_feedback',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('evaluator_name', sa.String(length=100), nullable=False),
sa.Column('evaluatee_name', sa.String(length=100), nullable=False),
sa.Column('evaluatee_department', sa.String(length=50), nullable=False),
sa.Column('evaluatee_position', sa.String(length=50), nullable=False),
sa.Column('situation', sa.Text(), nullable=False),
sa.Column('task', sa.Text(), nullable=False),
sa.Column('action', sa.Text(), nullable=False),
sa.Column('result', sa.Text(), nullable=False),
sa.Column('score', sa.Integer(), nullable=False),
sa.Column('points_earned', sa.Integer(), nullable=False),
sa.Column('feedback_date', sa.Date(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=80), nullable=False),
sa.Column('email', sa.String(length=120), nullable=False),
sa.Column('full_name', sa.String(length=100), nullable=False),
sa.Column('department', sa.String(length=50), nullable=False),
sa.Column('position', sa.String(length=50), nullable=False),
sa.Column('employee_id', sa.String(length=50), nullable=True),
sa.Column('password_hash', sa.String(length=255), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email'),
sa.UniqueConstraint('employee_id'),
sa.UniqueConstraint('username')
)
op.create_table('assessment',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('department', sa.String(length=50), nullable=False),
sa.Column('position', sa.String(length=50), nullable=False),
sa.Column('employee_name', sa.String(length=100), nullable=True),
sa.Column('assessment_data', sa.Text(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('department_capability',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('department', sa.String(length=50), nullable=False),
sa.Column('capability_id', sa.Integer(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['capability_id'], ['capability.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('department', 'capability_id', name='uq_dept_capability')
)
# 移除刪除舊表的操作,保留舊表不影響新系統運行
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('development_cards',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('employee_id', mysql.VARCHAR(length=32), nullable=True),
sa.Column('gaps', mysql.TEXT(), nullable=True),
sa.Column('short_term_goals', mysql.TEXT(), nullable=True),
sa.Column('mid_term_goals', mysql.TEXT(), nullable=True),
sa.Column('long_term_goals', mysql.TEXT(), nullable=True),
sa.Column('training_plan', mysql.TEXT(), nullable=True),
sa.Column('mentor', mysql.VARCHAR(length=100), nullable=True),
sa.Column('budget', mysql.VARCHAR(length=100), nullable=True),
sa.Column('due_date', sa.DATE(), nullable=True),
sa.Column('saved_at', mysql.DATETIME(), nullable=True),
sa.ForeignKeyConstraint(['employee_id'], ['employees.employee_id'], name='fk_dev_emp', onupdate='CASCADE', ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('development_cards', schema=None) as batch_op:
batch_op.create_index('idx_dev_employee', ['employee_id'], unique=False)
op.create_table('capabilities',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('l1_description', mysql.TEXT(), nullable=True),
sa.Column('l2_description', mysql.TEXT(), nullable=True),
sa.Column('l3_description', mysql.TEXT(), nullable=True),
sa.Column('l4_description', mysql.TEXT(), nullable=True),
sa.Column('l5_description', mysql.TEXT(), nullable=True),
sa.Column('is_active', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
op.create_table('PJ_ABC',
sa.Column('ID', mysql.INTEGER(), autoincrement=False, nullable=True),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('PJ_ABC', schema=None) as batch_op:
batch_op.create_index('ID', ['ID'], unique=False)
op.create_table('employees',
sa.Column('employee_id', mysql.VARCHAR(length=32), nullable=False),
sa.Column('employee_name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('department', mysql.VARCHAR(length=100), nullable=True),
sa.Column('position_title', mysql.VARCHAR(length=100), nullable=True),
sa.Column('level_title', mysql.VARCHAR(length=50), nullable=True),
sa.Column('supervisor_name', mysql.VARCHAR(length=100), nullable=True),
sa.Column('created_at', mysql.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
sa.Column('updated_at', mysql.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), nullable=False),
sa.PrimaryKeyConstraint('employee_id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
op.create_table('performance_cards',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('employee_id', mysql.VARCHAR(length=32), nullable=True),
sa.Column('kpi_1', mysql.DECIMAL(precision=5, scale=2), nullable=True),
sa.Column('kpi_2', mysql.DECIMAL(precision=5, scale=2), nullable=True),
sa.Column('kpi_3', mysql.DECIMAL(precision=5, scale=2), nullable=True),
sa.Column('overall_level', mysql.TINYINT(), autoincrement=False, nullable=True),
sa.Column('manager_rating', mysql.TINYINT(), autoincrement=False, nullable=True),
sa.Column('peer_rating', mysql.TINYINT(), autoincrement=False, nullable=True),
sa.Column('contribution', mysql.TEXT(), nullable=True),
sa.Column('saved_at', mysql.DATETIME(), nullable=True),
sa.ForeignKeyConstraint(['employee_id'], ['employees.employee_id'], name='fk_perf_emp', onupdate='CASCADE', ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('performance_cards', schema=None) as batch_op:
batch_op.create_index('idx_perf_employee', ['employee_id'], unique=False)
op.create_table('role_cards',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('employee_id', mysql.VARCHAR(length=32), nullable=True),
sa.Column('role_name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('role_department', mysql.VARCHAR(length=100), nullable=True),
sa.Column('responsibilities', mysql.TEXT(), nullable=True),
sa.Column('kpi_indicators', mysql.TEXT(), nullable=True),
sa.Column('saved_at', mysql.DATETIME(), nullable=True),
sa.ForeignKeyConstraint(['employee_id'], ['employees.employee_id'], name='fk_role_emp', onupdate='CASCADE', ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('role_cards', schema=None) as batch_op:
batch_op.create_index('idx_role_employee', ['employee_id'], unique=False)
op.create_table('members',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('name', mysql.VARCHAR(length=255), nullable=False),
sa.Column('phone', mysql.VARCHAR(length=255), nullable=False),
sa.Column('address', mysql.VARCHAR(length=255), nullable=False),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
op.create_table('users',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('username', mysql.VARCHAR(length=80), nullable=False),
sa.Column('email', mysql.VARCHAR(length=120), nullable=False),
sa.Column('password_hash', mysql.VARCHAR(length=200), nullable=False),
sa.Column('full_name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('department', mysql.VARCHAR(length=100), nullable=True),
sa.Column('position', mysql.VARCHAR(length=100), nullable=True),
sa.Column('role', mysql.VARCHAR(length=20), nullable=True),
sa.Column('is_active', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True),
sa.Column('created_at', mysql.DATETIME(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('users', schema=None) as batch_op:
batch_op.create_index('ix_users_username', ['username'], unique=False)
batch_op.create_index('ix_users_role', ['role'], unique=False)
batch_op.create_index('ix_users_email', ['email'], unique=False)
batch_op.create_index('ix_users_department', ['department'], unique=False)
op.create_table('reviews',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('employee_name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('department', mysql.VARCHAR(length=100), nullable=False),
sa.Column('period', mysql.VARCHAR(length=50), nullable=False),
sa.Column('items', mysql.JSON(), nullable=False),
sa.Column('total_score', mysql.INTEGER(), autoincrement=False, nullable=False),
sa.Column('grade', mysql.VARCHAR(length=20), nullable=False),
sa.Column('overall_comment', mysql.TEXT(), nullable=True),
sa.Column('created_at', mysql.DATETIME(), server_default=sa.text('(now())'), nullable=True),
sa.Column('updated_at', mysql.DATETIME(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('reviews', schema=None) as batch_op:
batch_op.create_index('ix_reviews_period', ['period'], unique=False)
batch_op.create_index('ix_reviews_id', ['id'], unique=False)
batch_op.create_index('ix_reviews_employee_name', ['employee_name'], unique=False)
batch_op.create_index('ix_reviews_department', ['department'], unique=False)
op.create_table('employee_points',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('employee_name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('department', mysql.VARCHAR(length=100), nullable=True),
sa.Column('position', mysql.VARCHAR(length=100), nullable=True),
sa.Column('total_points', mysql.INTEGER(), autoincrement=False, nullable=True),
sa.Column('monthly_points', mysql.INTEGER(), autoincrement=False, nullable=True),
sa.Column('year_month', mysql.VARCHAR(length=7), nullable=True),
sa.Column('rank', mysql.INTEGER(), autoincrement=False, nullable=True),
sa.Column('percentile', mysql.FLOAT(), nullable=True),
sa.Column('tier', mysql.VARCHAR(length=20), nullable=True),
sa.Column('created_at', mysql.DATETIME(), nullable=True),
sa.Column('updated_at', mysql.DATETIME(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('employee_points', schema=None) as batch_op:
batch_op.create_index('ix_employee_points_employee_name', ['employee_name'], unique=False)
batch_op.create_index('idx_total_points_desc', ['total_points'], unique=False)
batch_op.create_index('idx_monthly_points_desc', ['monthly_points'], unique=False)
op.create_table('monthly_rankings',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('ranking_month', sa.DATE(), nullable=False),
sa.Column('employee_name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('department', mysql.VARCHAR(length=50), nullable=False),
sa.Column('position', mysql.VARCHAR(length=50), nullable=False),
sa.Column('total_points', mysql.INTEGER(), autoincrement=False, nullable=False),
sa.Column('ranking', mysql.INTEGER(), autoincrement=False, nullable=False),
sa.Column('created_at', mysql.DATETIME(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
op.create_table('star_feedbacks',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('evaluator_name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('evaluator_department', mysql.VARCHAR(length=100), nullable=True),
sa.Column('evaluator_position', mysql.VARCHAR(length=100), nullable=True),
sa.Column('evaluatee_name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('evaluatee_department', mysql.VARCHAR(length=100), nullable=True),
sa.Column('evaluatee_position', mysql.VARCHAR(length=100), nullable=True),
sa.Column('situation', mysql.TEXT(), nullable=False),
sa.Column('task', mysql.TEXT(), nullable=False),
sa.Column('action', mysql.TEXT(), nullable=False),
sa.Column('result', mysql.TEXT(), nullable=False),
sa.Column('score', mysql.INTEGER(), autoincrement=False, nullable=False),
sa.Column('points_earned', mysql.INTEGER(), autoincrement=False, nullable=False),
sa.Column('feedback_date', sa.DATE(), nullable=True),
sa.Column('created_at', mysql.DATETIME(), nullable=True),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('star_feedbacks', schema=None) as batch_op:
batch_op.create_index('ix_star_feedbacks_evaluatee_name', ['evaluatee_name'], unique=False)
batch_op.create_index('ix_star_feedbacks_created_at', ['created_at'], unique=False)
op.create_table('competency_cards',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('employee_id', mysql.VARCHAR(length=32), nullable=True),
sa.Column('details', mysql.TEXT(), nullable=True),
sa.Column('saved_at', mysql.DATETIME(), nullable=True),
sa.ForeignKeyConstraint(['employee_id'], ['employees.employee_id'], name='fk_comp_emp', onupdate='CASCADE', ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('competency_cards', schema=None) as batch_op:
batch_op.create_index('idx_comp_employee', ['employee_id'], unique=False)
op.create_table('assessments',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('user_id', mysql.INTEGER(), autoincrement=False, nullable=False),
sa.Column('employee_name', mysql.VARCHAR(length=100), nullable=False),
sa.Column('department', mysql.VARCHAR(length=100), nullable=True),
sa.Column('position', mysql.VARCHAR(length=100), nullable=True),
sa.Column('assessment_data', mysql.TEXT(), nullable=True),
sa.Column('created_at', mysql.DATETIME(), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='assessments_ibfk_1'),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('assessments', schema=None) as batch_op:
batch_op.create_index('ix_assessments_employee_name', ['employee_name'], unique=False)
batch_op.create_index('ix_assessments_created_at', ['created_at'], unique=False)
op.create_table('nine_box_assessments',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('employee_id', mysql.VARCHAR(length=32), nullable=True),
sa.Column('performance_score', mysql.DECIMAL(precision=2, scale=1), nullable=True),
sa.Column('potential_score', mysql.DECIMAL(precision=2, scale=1), nullable=True),
sa.Column('category', mysql.VARCHAR(length=50), nullable=True),
sa.Column('priority', mysql.VARCHAR(length=20), nullable=True),
sa.Column('saved_at', mysql.DATETIME(), nullable=True),
sa.ForeignKeyConstraint(['employee_id'], ['employees.employee_id'], name='fk_nine_emp', onupdate='CASCADE', ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('nine_box_assessments', schema=None) as batch_op:
batch_op.create_index('idx_nine_employee', ['employee_id'], unique=False)
op.create_table('feedbacks',
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
sa.Column('employee_id', mysql.VARCHAR(length=32), nullable=True),
sa.Column('category_id', mysql.INTEGER(), autoincrement=False, nullable=True),
sa.Column('observation_date', sa.DATE(), nullable=False),
sa.Column('rating', mysql.TINYINT(), autoincrement=False, nullable=False),
sa.Column('situation', mysql.TEXT(), nullable=False),
sa.Column('task', mysql.TEXT(), nullable=False),
sa.Column('action', mysql.TEXT(), nullable=False),
sa.Column('result', mysql.TEXT(), nullable=False),
sa.Column('created_at', mysql.DATETIME(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False),
sa.ForeignKeyConstraint(['employee_id'], ['employees.employee_id'], name='fk_feedbacks_employee', onupdate='CASCADE', ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id'),
mysql_collate='utf8mb4_0900_ai_ci',
mysql_default_charset='utf8mb4',
mysql_engine='InnoDB'
)
with op.batch_alter_table('feedbacks', schema=None) as batch_op:
batch_op.create_index('idx_feedbacks_observation_date', ['observation_date'], unique=False)
batch_op.create_index('idx_feedbacks_employee', ['employee_id'], unique=False)
batch_op.create_index('idx_feedbacks_category', ['category_id'], unique=False)
op.drop_table('department_capability')
op.drop_table('assessment')
op.drop_table('user')
op.drop_table('star_feedback')
op.drop_table('employee_point')
op.drop_table('capability')
# ### end Alembic commands ###