fix: Backfill namespace_id in schema migration
ALTER TABLE
IF EXISTS parquet_file
- ADD COLUMN namespace_id INT NOT NULL;
+ ADD COLUMN namespace_id INT;
+
ALTER TABLE
IF EXISTS parquet_file
ADD FOREIGN KEY (namespace_id)
@@ -8,3 +9,11 @@ ALTER TABLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
+
+UPDATE parquet_file p
+ SET namespace_id=t.namespace_id
+ FROM table_name t
+ WHERE t.id=p.table_id;
+
+ALTER TABLE parquet_file
+ ALTER COLUMN namespace_id SET NOT NULL;
