From ac0d99281e89ed5abeb1ff641e31a046bcf40b91 Mon Sep 17 00:00:00 2001 From: jyong <718720800@qq.com> Date: Thu, 12 Dec 2024 09:48:25 +0800 Subject: [PATCH] add migration --- ...24_11_05_0326-49f175ff56cb_add_fat_test.py | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 api/migrations/versions/2024_11_05_0326-49f175ff56cb_add_fat_test.py diff --git a/api/migrations/versions/2024_11_05_0326-49f175ff56cb_add_fat_test.py b/api/migrations/versions/2024_11_05_0326-49f175ff56cb_add_fat_test.py new file mode 100644 index 0000000000..e236fc5571 --- /dev/null +++ b/api/migrations/versions/2024_11_05_0326-49f175ff56cb_add_fat_test.py @@ -0,0 +1,96 @@ +"""add_fat_test + +Revision ID: 49f175ff56cb +Revises: 43fa78bc3b7d +Create Date: 2024-11-05 03:26:22.578321 + +""" +from alembic import op +import models as models +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '49f175ff56cb' +down_revision = '01d6889832f7' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('component_failure', + sa.Column('FailureID', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('Date', sa.Date(), nullable=False), + sa.Column('Component', sa.String(length=255), nullable=False), + sa.Column('FailureMode', sa.String(length=255), nullable=False), + sa.Column('Cause', sa.String(length=255), nullable=False), + sa.Column('RepairAction', sa.Text(), nullable=True), + sa.Column('Technician', sa.String(length=255), nullable=False), + sa.PrimaryKeyConstraint('FailureID', name=op.f('component_failure_pkey')), + sa.UniqueConstraint('Date', 'Component', 'FailureMode', 'Cause', 'Technician', name='unique_failure_entry') + ) + op.create_table('component_failure_stats', + sa.Column('StatID', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('Component', sa.String(length=255), nullable=False), + sa.Column('FailureMode', sa.String(length=255), nullable=False), + sa.Column('Cause', sa.String(length=255), nullable=False), + sa.Column('PossibleAction', sa.Text(), nullable=True), + sa.Column('Probability', sa.Float(), nullable=False), + sa.Column('MTBF', sa.Float(), nullable=False), + sa.PrimaryKeyConstraint('StatID', name=op.f('component_failure_stats_pkey')) + ) + op.create_table('incident_data', + sa.Column('IncidentID', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('IncidentDescription', sa.Text(), nullable=False), + sa.Column('IncidentDate', sa.Date(), nullable=False), + sa.Column('Consequences', sa.Text(), nullable=True), + sa.Column('ResponseActions', sa.Text(), nullable=True), + sa.PrimaryKeyConstraint('IncidentID', name=op.f('incident_data_pkey')) + ) + op.create_table('maintenance', + sa.Column('MaintenanceID', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('MaintenanceType', sa.String(length=255), nullable=False), + sa.Column('MaintenanceDate', sa.Date(), nullable=False), + sa.Column('ServiceDescription', sa.Text(), nullable=True), + sa.Column('PartsReplaced', sa.Text(), nullable=True), + sa.Column('Technician', sa.String(length=255), nullable=False), + sa.PrimaryKeyConstraint('MaintenanceID', name=op.f('maintenance_pkey')) + ) + op.create_table('operational_data', + sa.Column('OperationID', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('CraneUsage', sa.Integer(), nullable=False), + sa.Column('LoadWeight', sa.Float(), nullable=False), + sa.Column('LoadFrequency', sa.Integer(), nullable=False), + sa.Column('EnvironmentalConditions', sa.Text(), nullable=True), + sa.PrimaryKeyConstraint('OperationID', name=op.f('operational_data_pkey')) + ) + op.create_table('reliability_data', + sa.Column('ComponentID', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('ComponentName', sa.String(length=255), nullable=False), + sa.Column('MTBF', sa.Float(), nullable=False), + sa.Column('FailureRate', sa.Float(), nullable=False), + sa.PrimaryKeyConstraint('ComponentID', name=op.f('reliability_data_pkey')) + ) + op.create_table('safety_data', + sa.Column('SafetyID', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('SafetyInspectionDate', sa.Date(), nullable=False), + sa.Column('SafetyFindings', sa.Text(), nullable=True), + sa.Column('SafetyIncidentDescription', sa.Text(), nullable=True), + sa.Column('ComplianceStatus', sa.String(length=50), nullable=False), + sa.PrimaryKeyConstraint('SafetyID', name=op.f('safety_data_pkey')) + ) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('safety_data') + op.drop_table('reliability_data') + op.drop_table('operational_data') + op.drop_table('maintenance') + op.drop_table('incident_data') + op.drop_table('component_failure_stats') + op.drop_table('component_failure') + # ### end Alembic commands ###