Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB Schema Creation Error using PostgreSQL #308

Open
Proxymiity opened this issue Aug 7, 2023 · 1 comment
Open

DB Schema Creation Error using PostgreSQL #308

Proxymiity opened this issue Aug 7, 2023 · 1 comment

Comments

@Proxymiity
Copy link

When initializing the database with Postgres, the relation IX_Username_1 is already used on admin (username):

CREATE TABLE admin (id BIGINT NOT NULL, username VARCHAR(255) DEFAULT NULL, password VARCHAR(255) NOT NULL, super BOOLEAN DEFAULT 'false' NOT NULL, active BOOLEAN DEFAULT 'true' NOT NULL, created TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, modified TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY(id));
CREATE UNIQUE INDEX IX_Username_1 ON admin (username);
[...]
CREATE UNIQUE INDEX IX_Username_1 ON mailbox (username);

This causes the following error: [42P07] ERROR: relation "ix_username_1" already exists.

Using orm:schema-tool:create --dump-sql and changing the relation to ix_username_2 solves the problem.

@frlan
Copy link

frlan commented Mar 23, 2024

Unsure whether this is the best solution

SELECT
    tablename,
    indexname,
    indexdef
FROM
    pg_indexes
WHERE
    indexname = 'ix_username_1'
ORDER BY
    tablename,
    indexname;

Results in

 tablename |   indexname   |                                  indexdef                                  
-----------+---------------+----------------------------------------------------------------------------
 mailbox   | ix_username_1 | CREATE UNIQUE INDEX ix_username_1 ON public.mailbox USING btree (username)
(1 Zeile)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants