Skip to content

db export emits non-restorable SQL for array columns and dependency ordering #283

Description

@agent-zhang-beihai

What happens

A full SQL export with functions, sequences and views could not restore into clean PostgreSQL 16. The file is a JSON envelope despite .sql output; extracted SQL creates triggers before functions, creates FK constraints before referenced tables, emits an array column as aliases ARRAY without element type, and serializes text[] values as JSON literals like '[]'.

Command

npx @insforge/cli db export --include-functions --include-sequences --include-views --output backup.sql

Error

function set_inventory_updated_at() does not exist; syntax error near ARRAY; malformed array literal: []

Expected

The exported SQL should restore into an empty supported PostgreSQL database with ON_ERROR_STOP=1.

Workaround

Extracted the JSON data field and normalized dependency ordering/type, but array data literals still require semantic rewriting, so resize gate was stopped.

Triage finding

All four symptoms reproduced in current main — CLI db/export.ts:51 unwraps only content while the API returns data, and backend database-advance.service.ts emits triggers/FKs before their functions/tables (L375-416 vs L510-534), uses ELSE data_type yielding bare ARRAY (L227-239), and JSON.stringifies arrays with no Array.isArray() guard (L474-483); nothing fixed in 0.2.7/0.2.8, and open-but-stalled PR #211 covers only the envelope, leaving the three backend defects untracked.

· win32 10.0.26200

Filed automatically from user feedback.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions