Skip to content

ERROR: SEQUENCE already exists during TableUtils.createTableIfNotExists #85

@EMaksymenko

Description

@EMaksymenko

Could you please handle properly situation when TableUtils.createTableIfNotExists() method is used to add CREATE SEQUENCE IF NOT EXISTS in Postgres database imlementation?

Becasue now it fails due to even if CREATE TABLE has IF NOT EXISTS statement, CREATE SEQUENCE has not.

Exception in thread "main" java.sql.SQLException: SQL statement failed: CREATE SEQUENCE "local_user_session_id_seq"
	at com.j256.ormlite.table.TableUtils.doStatements(TableUtils.java:395)
	at com.j256.ormlite.table.TableUtils.doCreateTable(TableUtils.java:371)
	at com.j256.ormlite.table.TableUtils.doCreateTable(TableUtils.java:356)
	at com.j256.ormlite.table.TableUtils.createTableIfNotExists(TableUtils.java:74)
	at vision.combat.c4.node.ormlite.ORMCoreDataManager.<init>(ORMCoreDataManager.kt:17)
	at vision.combat.c4.node.ApplicationKt.initCore(Application.kt:119)
	at vision.combat.c4.node.ApplicationKt.main(Application.kt:38)
Caused by: org.postgresql.util.PSQLException: ERROR: SEQUENCE "local_user_session_id_seq" already exists
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2734)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2421)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:372)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:518)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:435)
	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:196)
	at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:182)
	at com.j256.ormlite.jdbc.JdbcCompiledStatement.runExecute(JdbcCompiledStatement.java:73)
Image

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