-- Extract Novels from NovelService database
-- Run this against: NovelService PostgreSQL database
-- Output: CSV or use COPY TO for bulk export

-- Option 1: Simple SELECT for review/testing
SELECT
    "Id",
    "CreatedTime",
    "LastUpdatedTime"
FROM "Novels"
ORDER BY "Id";

-- Option 2: Generate INSERT statements
SELECT format(
    'INSERT INTO "Novels" ("Id", "CreatedTime", "LastUpdatedTime") VALUES (%s, %L, %L) ON CONFLICT ("Id") DO NOTHING;',
    "Id",
    "CreatedTime",
    "LastUpdatedTime"
)
FROM "Novels"
ORDER BY "Id";

-- Option 3: Export to CSV (run from psql)
-- \copy (SELECT "Id", "CreatedTime", "LastUpdatedTime" FROM "Novels" ORDER BY "Id") TO '/tmp/novels_export.csv' WITH CSV HEADER;
