-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Issue 1: cds deploy --to postgres accepts command but doesn't create schema
Labels
bugclipostgresqlux
Description
The command cds deploy --to postgres is accepted by the CLI but only imports CSV data without creating the database schema (tables, views). This leads to confusion as cds deploy --to sqlite works perfectly (creating schema + importing data), but cds deploy --to postgres does not behave identically.
Steps to Reproduce
-
Create a new CAP project:
cds init my-project cd my-project cds add sample cds add postgres npm install -
Start PostgreSQL (e.g., via Docker):
docker run -d -p 5432:5432 -e POSTGRES_PASSWORD=postgres postgres:17
-
Configure
.cdsrc.json:{ "requires": { "db": { "kind": "postgres", "credentials": { "host": "localhost", "port": 5432, "user": "postgres", "password": "postgres", "database": "bookshop" } } } } -
Run deploy:
cds deploy --to postgres
Expected Behavior
One of the following:
- Create schema + import data (like
cds deploy --to sqlitedoes) - Throw an error with clear message:
"postgres" is not supported for --to, use --profile pg instead
Actual Behavior
- Command succeeds without error
- Only CSV data is imported
- No tables/views are created
- Database remains empty (except for some imported rows that fail)
Output:
> init from db/data/sap.capire.bookshop-Authors.csv
/> successfully deployed to localhost:5432
But querying the database shows no tables exist.
Root Cause Analysis
cds help deploy lists only "sqlite" and "hana" as supported targets:
SYNOPSIS
cds deploy [ <model> ] [ --to <database> ]
OPTIONS
--to <database> sqlite | hana
PostgreSQL is not listed, yet the command is accepted. The --to flag seems to be ignored, resulting in partial deployment.
Workaround
Use the correct command:
cds deploy --profile pg # This works correctlyOr for explicit deployment:
cds deploySuggested Solution
Option A (preferred): Support --to postgres properly with identical behavior to SQLite
Implement full schema deployment for PostgreSQL to match cds deploy --to sqlite behavior:
- Create database schema (tables, views, indexes)
- Import CSV data
- Set up constraints and relationships
This provides consistent UX across all database types.
Option B: Throw an error when --to postgres is used:
Error: "postgres" is not a valid target for --to flag.
For PostgreSQL deployment, use: cds deploy --profile pg
Supported targets: sqlite, hana
Environment
- @sap/cds: v9.6.3
- @cap-js/postgres: v2.1.2
- Node.js: v22.22.0
- PostgreSQL: 17
- OS: Ubuntu 24.04 (WSL2)
Related Issues
- Cryptic error message when db-ext[pg] profile is missing #1472
- Missing documentation for db-ext model system with PostgreSQL #1473
Additional Context
The confusion stems from the fact that cds deploy --to sqlite works perfectly (creating schema + importing data), leading developers to naturally assume --to postgres would behave identically. This inconsistency creates a poor developer experience.