Skip to content

Skip table create #1684

@alikhd1

Description

@alikhd1

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions