@@ -53,10 +53,13 @@ def export_table_data(cursor, table_name, output_file):
5353 table_name: Name of table to export
5454 output_file: File object to write INSERT statements to
5555 """
56+ # Columns to exclude (removed from schema)
57+ excluded_columns = {'is_subscribed' }
58+
5659 # Boolean columns (SQLite stores as INTEGER 0/1, PostgreSQL needs true/false)
5760 # These are known boolean columns in our schema
5861 boolean_columns = {
59- 'is_subscribed' , ' itunes_explicit' , 'is_active' , 'is_admin' ,
62+ 'itunes_explicit' , 'is_active' , 'is_admin' ,
6063 'email_digest_enabled' , 'smtp_use_tls'
6164 }
6265
@@ -73,16 +76,19 @@ def export_table_data(cursor, table_name, output_file):
7376 output_file .write (f"-- No data in { table_name } \n " )
7477 return
7578
76- # Get column names from cursor description
77- columns = [desc [0 ] for desc in cursor .description ]
79+ # Get column names from cursor description, excluding removed columns
80+ all_columns = [desc [0 ] for desc in cursor .description ]
81+ columns = [col for col in all_columns if col not in excluded_columns ]
82+ keep_indices = [i for i , col in enumerate (all_columns ) if col not in excluded_columns ]
7883 col_list = ", " .join (columns )
7984
8085 output_file .write (f"-- Inserting { len (rows )} rows into { table_name } \n " )
8186
8287 for row in rows :
8388 values = []
84- for idx , val in enumerate (row ):
85- col_name = columns [idx ]
89+ for idx in keep_indices :
90+ col_name = all_columns [idx ]
91+ val = row [idx ]
8692 # Handle JSON columns - keep as-is, just wrap in single quotes
8793 if col_name in json_columns :
8894 if val is None :
0 commit comments