pgloader icon indicating copy to clipboard operation
pgloader copied to clipboard

Skip table create

Open alikhd1 opened this issue 3 months ago • 0 comments

Description

I’m migrating data from an existing SQLite database into a PostgreSQL database using pgloader.
My PostgreSQL target database already has some tables created by Alembic migrations (for example, alembic_version).

When I run pgloader, it attempts to create all tables from SQLite, even if they already exist in PostgreSQL.
This causes errors like:

ERROR Database error 42P07: relation "alembic_version" already exists
QUERY: CREATE TABLE alembic_version
(
  version_num text
);
FATAL Failed to create the schema, see above.

Steps to Reproduce

  1. Create a PostgreSQL database with an existing table, e.g.:
CREATE TABLE alembic_version (version_num TEXT);
  1. Run pgloader:
pgloader sqlite:///source.db postgresql://user:pass@host:5432/target
  1. pgloader fails because it tries to CREATE TABLE alembic_version again.

Expected Behavior

There should be a way to:

  • Import data into existing PostgreSQL tables without re-creating them.
  • Or explicitly exclude some tables (like alembic_version) from schema creation, while still importing the rest.

What I Tried

  • Adding WITH include no drop → still attempts to create tables.
  • Adding no create tables under WITH → parse error (ESRAP-PARSE-ERROR).
  • Excluding tables with EXCLUDING TABLE NAMES MATCHING ~/alembic_version/ also didn’t work as expected (still tries to create schema).

Environment

  • pgloader version: 3.6.7~devel

Question / Feature Request

Is there a supported way to only load data into existing schema without pgloader trying to re-create tables?
If not, could we add a no create tables option or make EXCLUDING TABLE NAMES skip schema creation for those tables?

pgloader fails when target DB already has existing tables (alembic_version already exists)

Description

I’m migrating data from an existing SQLite database into a PostgreSQL database using pgloader.
My PostgreSQL target database already has some tables created by Alembic migrations (for example, alembic_version).

When I run pgloader, it attempts to create all tables from SQLite, even if they already exist in PostgreSQL.
This causes errors like:

ERROR Database error 42P07: relation "alembic_version" already exists
QUERY: CREATE TABLE alembic_version
(
  version_num text
);
FATAL Failed to create the schema, see above.

Steps to Reproduce

  1. Create a PostgreSQL database with an existing table, e.g.:
CREATE TABLE alembic_version (version_num TEXT);
  1. Run pgloader:
pgloader sqlite:///source.db postgresql://user:pass@host:5432/target
  1. pgloader fails because it tries to CREATE TABLE alembic_version again.

Expected Behavior

There should be a way to:

  • Import data into existing PostgreSQL tables without re-creating them.
  • Or explicitly exclude some tables (like alembic_version) from schema creation, while still importing the rest.

What I Tried

  • Adding WITH include no drop → still attempts to create tables.
  • Adding no create tables under WITH → parse error (ESRAP-PARSE-ERROR).
  • Excluding tables with EXCLUDING TABLE NAMES MATCHING ~/alembic_version/ also didn’t work as expected (still tries to create schema).

Environment

  • pgloader version: 3.6.7~devel

Question / Feature Request

Is there a supported way to only load data into existing schema without pgloader trying to re-create tables?
If not, could we add a no create tables option or make EXCLUDING TABLE NAMES skip schema creation for those tables?

alikhd1 avatar Sep 24 '25 10:09 alikhd1