-- Insert Volumes into UserNovelDataService database -- Run this against: UserNovelDataService PostgreSQL database -- -- PREREQUISITE: -- 1. Ensure the Volumes table exists (run EF migrations first if needed) -- 2. Novels must be inserted first (FK constraint) -- 3. Extract volumes from NovelService using 03_extract_volumes_from_novelservice.sql -- Option 1: If you have a CSV file from export -- \copy "Volumes" ("Id", "NovelId", "CreatedTime", "LastUpdatedTime") FROM '/tmp/volumes_export.csv' WITH CSV HEADER; -- Option 2: Direct cross-database insert using dblink -- First, install dblink extension if not already done: -- CREATE EXTENSION IF NOT EXISTS dblink; -- Example using dblink (adjust connection string): /* INSERT INTO "Volumes" ("Id", "NovelId", "CreatedTime", "LastUpdatedTime") SELECT "Id"::bigint, "NovelId"::bigint, "CreatedTime"::timestamp with time zone, "LastUpdatedTime"::timestamp with time zone FROM dblink( 'host=localhost port=5432 dbname=novelservice user=postgres password=yourpassword', 'SELECT "Id", "NovelId", "CreatedTime", "LastUpdatedTime" FROM "Volume"' ) AS t("Id" bigint, "NovelId" bigint, "CreatedTime" timestamp with time zone, "LastUpdatedTime" timestamp with time zone) ON CONFLICT ("Id") DO UPDATE SET "NovelId" = EXCLUDED."NovelId", "LastUpdatedTime" = EXCLUDED."LastUpdatedTime"; */ -- Option 3: Paste generated INSERT statements from extraction script here -- INSERT INTO "Volumes" ("Id", "NovelId", "CreatedTime", "LastUpdatedTime") VALUES (...) ON CONFLICT ("Id") DO NOTHING;