| def upgrade(): | def upgrade(): | ||||
| # ### commands auto generated by Alembic - please adjust! ### | # ### commands auto generated by Alembic - please adjust! ### | ||||
| op.drop_table('component_failure_stats') | |||||
| op.drop_table('reliability_data') | |||||
| op.drop_table('maintenance') | |||||
| op.drop_table('operational_data') | |||||
| op.drop_table('component_failure') | |||||
| op.drop_table('tool_providers') | |||||
| op.drop_table('safety_data') | |||||
| op.drop_table('incident_data') | |||||
| with op.batch_alter_table('pipelines', schema=None) as batch_op: | with op.batch_alter_table('pipelines', schema=None) as batch_op: | ||||
| batch_op.drop_column('mode') | batch_op.drop_column('mode') | ||||
| with op.batch_alter_table('pipelines', schema=None) as batch_op: | with op.batch_alter_table('pipelines', schema=None) as batch_op: | ||||
| batch_op.add_column(sa.Column('mode', sa.VARCHAR(length=255), autoincrement=False, nullable=False)) | batch_op.add_column(sa.Column('mode', sa.VARCHAR(length=255), autoincrement=False, nullable=False)) | ||||
| op.create_table('incident_data', | |||||
| sa.Column('IncidentID', sa.INTEGER(), autoincrement=True, nullable=False), | |||||
| sa.Column('IncidentDescription', sa.TEXT(), autoincrement=False, nullable=False), | |||||
| sa.Column('IncidentDate', sa.DATE(), autoincrement=False, nullable=False), | |||||
| sa.Column('Consequences', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.Column('ResponseActions', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.PrimaryKeyConstraint('IncidentID', name='incident_data_pkey') | |||||
| ) | |||||
| op.create_table('safety_data', | |||||
| sa.Column('SafetyID', sa.INTEGER(), autoincrement=True, nullable=False), | |||||
| sa.Column('SafetyInspectionDate', sa.DATE(), autoincrement=False, nullable=False), | |||||
| sa.Column('SafetyFindings', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.Column('SafetyIncidentDescription', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.Column('ComplianceStatus', sa.VARCHAR(length=50), autoincrement=False, nullable=False), | |||||
| sa.PrimaryKeyConstraint('SafetyID', name='safety_data_pkey') | |||||
| ) | |||||
| op.create_table('tool_providers', | |||||
| sa.Column('id', sa.UUID(), server_default=sa.text('uuid_generate_v4()'), autoincrement=False, nullable=False), | |||||
| sa.Column('tenant_id', sa.UUID(), autoincrement=False, nullable=False), | |||||
| sa.Column('tool_name', sa.VARCHAR(length=40), autoincrement=False, nullable=False), | |||||
| sa.Column('encrypted_credentials', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.Column('is_enabled', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=False), | |||||
| sa.Column('created_at', postgresql.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP(0)'), autoincrement=False, nullable=False), | |||||
| sa.Column('updated_at', postgresql.TIMESTAMP(), server_default=sa.text('CURRENT_TIMESTAMP(0)'), autoincrement=False, nullable=False), | |||||
| sa.PrimaryKeyConstraint('id', name='tool_provider_pkey'), | |||||
| sa.UniqueConstraint('tenant_id', 'tool_name', name='unique_tool_provider_tool_name') | |||||
| ) | |||||
| op.create_table('component_failure', | |||||
| sa.Column('FailureID', sa.INTEGER(), autoincrement=True, nullable=False), | |||||
| sa.Column('Date', sa.DATE(), autoincrement=False, nullable=False), | |||||
| sa.Column('Component', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.Column('FailureMode', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.Column('Cause', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.Column('RepairAction', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.Column('Technician', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.PrimaryKeyConstraint('FailureID', name='component_failure_pkey'), | |||||
| sa.UniqueConstraint('Date', 'Component', 'FailureMode', 'Cause', 'Technician', name='unique_failure_entry') | |||||
| ) | |||||
| op.create_table('operational_data', | |||||
| sa.Column('OperationID', sa.INTEGER(), autoincrement=True, nullable=False), | |||||
| sa.Column('CraneUsage', sa.INTEGER(), autoincrement=False, nullable=False), | |||||
| sa.Column('LoadWeight', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False), | |||||
| sa.Column('LoadFrequency', sa.INTEGER(), autoincrement=False, nullable=False), | |||||
| sa.Column('EnvironmentalConditions', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.PrimaryKeyConstraint('OperationID', name='operational_data_pkey') | |||||
| ) | |||||
| op.create_table('maintenance', | |||||
| sa.Column('MaintenanceID', sa.INTEGER(), autoincrement=True, nullable=False), | |||||
| sa.Column('MaintenanceType', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.Column('MaintenanceDate', sa.DATE(), autoincrement=False, nullable=False), | |||||
| sa.Column('ServiceDescription', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.Column('PartsReplaced', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.Column('Technician', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.PrimaryKeyConstraint('MaintenanceID', name='maintenance_pkey') | |||||
| ) | |||||
| op.create_table('reliability_data', | |||||
| sa.Column('ComponentID', sa.INTEGER(), autoincrement=True, nullable=False), | |||||
| sa.Column('ComponentName', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.Column('MTBF', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False), | |||||
| sa.Column('FailureRate', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False), | |||||
| sa.PrimaryKeyConstraint('ComponentID', name='reliability_data_pkey') | |||||
| ) | |||||
| op.create_table('component_failure_stats', | |||||
| sa.Column('StatID', sa.INTEGER(), autoincrement=True, nullable=False), | |||||
| sa.Column('Component', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.Column('FailureMode', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.Column('Cause', sa.VARCHAR(length=255), autoincrement=False, nullable=False), | |||||
| sa.Column('PossibleAction', sa.TEXT(), autoincrement=False, nullable=True), | |||||
| sa.Column('Probability', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False), | |||||
| sa.Column('MTBF', sa.DOUBLE_PRECISION(precision=53), autoincrement=False, nullable=False), | |||||
| sa.PrimaryKeyConstraint('StatID', name='component_failure_stats_pkey') | |||||
| ) | |||||
| # ### end Alembic commands ### | # ### end Alembic commands ### |