mirror of
https://github.com/simstudioai/sim.git
synced 2026-10-29 18:47:25 +08:00
improvement(tables): backfill default views for existing tables (#6899)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
-- migration-safe: data-only backfill after table creation began seeding default views;
|
||||
-- empty config inherits legacy table metadata until each layout field is explicitly saved.
|
||||
-- Idempotent on replay and safe against concurrent default creation through the partial unique index.
|
||||
INSERT INTO "table_views" (
|
||||
"id",
|
||||
"table_id",
|
||||
"workspace_id",
|
||||
"name",
|
||||
"config",
|
||||
"is_default",
|
||||
"created_by",
|
||||
"created_at",
|
||||
"updated_at"
|
||||
)
|
||||
SELECT
|
||||
gen_random_uuid()::text,
|
||||
t."id",
|
||||
t."workspace_id",
|
||||
'Default',
|
||||
'{}'::jsonb,
|
||||
true,
|
||||
t."created_by",
|
||||
t."created_at",
|
||||
now()
|
||||
FROM "user_table_definitions" t
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM "table_views" v
|
||||
WHERE v."table_id" = t."id"
|
||||
AND v."is_default" = true
|
||||
)
|
||||
ON CONFLICT ("table_id") WHERE "is_default" = true DO NOTHING;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2101,6 +2101,13 @@
|
||||
"when": 1787360221351,
|
||||
"tag": "0300_hesitant_war_machine",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 301,
|
||||
"version": "7",
|
||||
"when": 1787365065919,
|
||||
"tag": "0301_backfill_table_default_views",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user