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

Unique index naming conflict with atlas #2421

Closed
pzeinlinger opened this issue Mar 23, 2022 · 2 comments · Fixed by #2433
Closed

Unique index naming conflict with atlas #2421

pzeinlinger opened this issue Mar 23, 2022 · 2 comments · Fixed by #2433

Comments

@pzeinlinger
Copy link

  • [X ] The issue is present in the latest release.
  • [ X] I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Using atlas as migration engine leads to a naming conflict of columns with unique constraints using sqlite. Migrations with Postgres work as expected.

Output of debug client:

2022/03/22 19:20:01 driver.Tx(8f23a6a6-c886-4be1-be6d-067742351aef): started
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef).Query: query=PRAGMA foreign_keys args=[]
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef).Query: query=SELECT sqlite_version(), foreign_keys from pragma_foreign_keys args=[]
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef).Query: query=SELECT name FROM pragma_collation_list() args=[]
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef).Query: query=SELECT `name`, `file` FROM pragma_database_list() WHERE name IN (?) args=[main]
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef).Query: query=SELECT `name`, `sql` FROM sqlite_master WHERE `type` = 'table' AND `name` NOT LIKE 'sqlite_%' AND name IN (?, ?) args=[groups users]
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef).Exec: query=CREATE TABLE `groups` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` text NOT NULL) args=[]
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef).Exec: query=CREATE UNIQUE INDEX `name` ON `groups` (`name`) args=[]
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef).Exec: query=CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` text NOT NULL) args=[]
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef).Exec: query=CREATE UNIQUE INDEX `name` ON `users` (`name`) args=[]
2022/03/22 19:20:01 Tx(8f23a6a6-c886-4be1-be6d-067742351aef): rollbacked
2022/03/22 19:20:01 failed creating schema resources: sql/schema: create index "name" to table: "users": index name already exists
exit status 1

db: sqlite

Expected Behavior 🤔

Ent's old migration engine used sqlite's auto index

CREATE TABLE `users`(`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `name` varchar(255) UNIQUE NOT NULL)

Steps to Reproduce 🕹

Minimal Reproducible Example

Your Environment 🌎

Tech Version
Go 1.18.0
Ent v0.10.2-0.20220321093754-edd968490ea2
Atlas v0.3.8-0.20220314111236-b2171e04c5b2
Database SQLite
Driver https://github.com/mattn/go-sqlite3
@pzeinlinger
Copy link
Author

Still present on master as of today. I updated the demo repo.

@a8m
Copy link
Member

a8m commented Mar 28, 2022

Thanks for reporting this @pzeinlinger 🙏

Fixed with #2433

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

Successfully merging a pull request may close this issue.

2 participants