You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sync() with new alter method fails with dataType enum #7649
dialect: postgresFor issues and PRs. Things that involve PostgreSQL (and do not involve all dialects).releasedtype: bugDEPRECATED: replace with the "bug" issue type
Reacted by Radon Rosborough, kukoo1, Erick Katzenstein, Song Seunggeun, Buster Styren, FujiBilly, Kevin Peters, danielreibl, Kento Yamashita, David Ilizarov and 12 more
This issue, together with #7606 effectively makes the alter option useless for anything beyond unrelated tables with no enums.
This one seems to stem from this bunch of statements:
ALTER TABLE "users" ALTER COLUMN "provider" SET NOT NULL;
ALTER TABLE "users" ALTER COLUMN "provider" SET DEFAULT 'local';
CREATE TYPE "public"."enum_users_provider" AS ENUM('local', 'google', 'facebook');
ALTER TABLE "users" ALTER COLUMN "provider" TYPE "public"."enum_users_provider" USING ("provider"::"public"."enum_users_provider");
Some kind of check should be added to check if the type exists before executing CREATE TYPE.
Reacted by Radon Rosborough, Erick Katzenstein and jscul
This can be fixed by changing line 783 in query-generator from:
let sql = 'CREATE TYPE ' + enumName + ' AS ' + values + ';';
To:
let sql = 'DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'enum_' + tableName + '_' + attr + '') THEN CREATE TYPE ' + enumName + ' AS ' + values + '; END IF; END$$;'
I've never contributed to OSS before, so I don't feel that confident about creating a push request. I can figure it out and create one if you think this solution is acceptable. I worry that I wasn't able to use the enumName as generated a few lines up - postgres throws an error if I don't recreate the name without the namespace. Should I also then refactor the pgEnumName function to pull from a new, third function that returns a pure name without the namespace for commonality?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
dialect: postgresFor issues and PRs. Things that involve PostgreSQL (and do not involve all dialects).releasedtype: bugDEPRECATED: replace with the "bug" issue type
Activity
FREEZX commentedon Jun 14, 2017
This issue, together with #7606 effectively makes the alter option useless for anything beyond unrelated tables with no enums.
This one seems to stem from this bunch of statements:
Some kind of check should be added to check if the type exists before executing CREATE TYPE.
skn3 commentedon Jul 9, 2017
also related to #7606 and #7915
GrigoryGraborenko commentedon Jul 21, 2017
This can be fixed by changing line 783 in query-generator from:
let sql = 'CREATE TYPE ' + enumName + ' AS ' + values + ';';
To:
let sql = 'DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'enum_' + tableName + '_' + attr + '') THEN CREATE TYPE ' + enumName + ' AS ' + values + '; END IF; END$$;'
I've never contributed to OSS before, so I don't feel that confident about creating a push request. I can figure it out and create one if you think this solution is acceptable. I worry that I wasn't able to use the enumName as generated a few lines up - postgres throws an error if I don't recreate the name without the namespace. Should I also then refactor the pgEnumName function to pull from a new, third function that returns a pure name without the namespace for commonality?
stale commentedon Sep 19, 2017
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂
techsin commentedon Nov 10, 2017
I've this exact issue
thebeachdev commentedon Dec 3, 2017
I'm getting this issue for my tests, not sure what's causing it.
Vincz commentedon Feb 8, 2018
Getting the same issue. Enum don't work with sync alter.
Vardiak commentedon Mar 10, 2018
This error is still occurring with latest version, any idea ?
papigers commentedon Aug 30, 2018
Bump? I'm getting the same
IgorSzymanski commentedon Sep 14, 2018
v. 4.38.1
The error is still there in
alter: truemode.force: truedoes the trick in development, but no data is persisted for obvious reasons.49 remaining items
fix(postgres): sync with alter method fails with dataType enum (seque…
fix(postgres): sync with alter method fails with dataType enum (seque…
fix(postgres): sync with alter method fails with dataType enum (seque…
fix(postgres): sync with alter method fails with dataType enum (seque…
fix(postgres): sync with alter method fails with dataType enum (seque…
fix(postgres): sync with alter method fails with dataType enum (seque…
fix(postgres): sync with alter method fails with dataType enum (#15738)
aristov commentedon Mar 5, 2023
🎉
ephys commentedon Mar 7, 2023
Reopening because we still need to merge #15718 for v6 :)
Edit: Oh well the PR was already in a good state, so, uh, merged ¯\_(ツ)_/¯
github-actions commentedon Mar 7, 2023
🎉 This issue has been resolved in version 6.29.1 🎉
The release is available on:
Your semantic-release bot 📦🚀
DN92 commentedon Mar 11, 2023