Initial import: shopdb-flask multi-site asset platform
Flask + Vue rewrite of the classic-ASP shopdb, built as a plugin framework so sister GE Aerospace sites can adopt it. Product version 0.7.0-pre-0.8.0, plugin contract 0.11.0, 966 backend tests. Key entry points: - docs/INSTALL-WINDOWS-IIS.md - tested Windows + IIS install runbook (own-site and subpath deployment methods) - docs/PILOT-DEPLOY.md - production pilot: stand up + import + verify - docs/IMPORT-API.md - schema-agnostic legacy data import contract - scripts/site_imports/wjf/ - West Jefferson reference import loader - docs/adr/ - twelve accepted architecture decision records
This commit is contained in:
57
migrations/versions/7d25_drop_redundant_indexes.py
Normal file
57
migrations/versions/7d25_drop_redundant_indexes.py
Normal file
@@ -0,0 +1,57 @@
|
||||
"""Drop redundant secondary indexes duplicating a named idx_* / unique index.
|
||||
|
||||
The DB review found five non-unique secondary indexes that duplicate an existing
|
||||
index on the same column: the auto-named ix_* from a column index=True alongside
|
||||
a named idx_* in __table_args__ (communications.assetid, and the hostname on
|
||||
computers/networkdevices/printers), plus idx_usb_serial duplicating the
|
||||
serialnumber unique index on usbdevices. Each redundant pair costs insert/update
|
||||
maintenance with zero read benefit. The models had the redundant index source
|
||||
removed; this drops the live duplicates so the schema matches the models.
|
||||
|
||||
Idempotent (skips a missing table/index); real downgrade recreates them.
|
||||
|
||||
Revision ID: 7d25_drop_redundant_indexes
|
||||
Revises: 7d24_customfield_searchable
|
||||
Create Date: 2026-07-13
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '7d25_drop_redundant_indexes'
|
||||
down_revision = '7d24_customfield_searchable'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
# (table, index name, columns, unique) - columns/unique used only to recreate on
|
||||
# downgrade. All non-unique; the surviving idx_* / unique index still covers each.
|
||||
_REDUNDANT = [
|
||||
('communications', 'ix_communications_assetid', ['assetid'], False),
|
||||
('computers', 'ix_computers_hostname', ['hostname'], False),
|
||||
('networkdevices', 'ix_networkdevices_hostname', ['hostname'], False),
|
||||
('printers', 'ix_printers_hostname', ['hostname'], False),
|
||||
('usbdevices', 'idx_usb_serial', ['serialnumber'], False),
|
||||
]
|
||||
|
||||
|
||||
def _index_names(insp, table):
|
||||
return {i['name'] for i in insp.get_indexes(table)}
|
||||
|
||||
|
||||
def upgrade():
|
||||
bind = op.get_bind()
|
||||
insp = sa.inspect(bind)
|
||||
tables = set(insp.get_table_names())
|
||||
for table, name, _cols, _unique in _REDUNDANT:
|
||||
if table in tables and name in _index_names(insp, table):
|
||||
op.drop_index(name, table_name=table)
|
||||
|
||||
|
||||
def downgrade():
|
||||
bind = op.get_bind()
|
||||
insp = sa.inspect(bind)
|
||||
tables = set(insp.get_table_names())
|
||||
for table, name, cols, unique in _REDUNDANT:
|
||||
if table in tables and name not in _index_names(insp, table):
|
||||
op.create_index(name, table, cols, unique=unique)
|
||||
Reference in New Issue
Block a user