"""Migration 0004 — create raw SQLite table ``tls_ref_data``. Replaces the ``TlsDB.csv`` reference file with a proper SQLite table. The table stores TLS field-code metadata: human-readable meaning and data type for each field code used in TLS flow data. """ from django.db import migrations # Raw SQL for creating the tls_ref_data table CREATE_TLS_REF_DATA = """ CREATE TABLE IF NOT EXISTS tls_ref_data ( id INTEGER PRIMARY KEY AUTOINCREMENT, field_code TEXT NOT NULL UNIQUE, meaning TEXT NOT NULL DEFAULT '', data_type TEXT NOT NULL DEFAULT '' ); """ DROP_TLS_REF_DATA = """ DROP TABLE IF EXISTS tls_ref_data; """ class Migration(migrations.Migration): """Create ``tls_ref_data`` table via raw SQL — no Django model needed.""" dependencies = [ ('tianxuan_analysis', '0003_analysisrun_sqlite_table'), ] operations = [ migrations.RunSQL( sql=CREATE_TLS_REF_DATA, reverse_sql=DROP_TLS_REF_DATA, state_operations=None, ), ]