cockroachdb / sequelize-cockroachdb

Use Sequelize and CockroachDB together
Apache License 2.0
53 stars 16 forks source link

Fork Sequelize CLI To Support Sequelize-Cockroach DB #146

Open hkd987 opened 2 years ago

hkd987 commented 2 years ago

While cockroach db does not recommend using sequelize cli to handle migrations many people looking to migrate are already doing this and need a supported path forward.

I was able to tinker around and found that a path forward for using the sequelize-cockroachdb lib with the sequelize-cli is as simple as updating this line here https://github.com/sequelize/cli/blob/main/src/helpers/generic-helper.js#L14.

This could be a very simple way to support the sequelize cli moving forward. Lets discuss or we can close this issue if this is a wont do thing.

hkd987 commented 2 years ago

Could possible be related to

vy-ton commented 2 years ago

Hi @hkd987, PM at Cockroach Labs here.

While cockroach db does not recommend using sequelize cli to handle migrations many people looking to migrate are already doing this and need a supported path forward.

Could you describe what you tried to do with migrations and any errors? The issue you linked might be outdated.

hkd987 commented 2 years ago

Few issues but I was able to use the sequelize-cockroachdb lib for my migration.

The first issue was that to_regclass() throws an error when the search path was empty but should return null since Postgres 9.4.

The other issue was related to CITEXT, so no need to get into that.

Both issues are not sequelize issues.

vy-ton commented 2 years ago

Another Serverless user reported the error:

to_regclass() throws an error when the search path was empty but should return null since Postgres 9.4.

cc @rafiss for triaging and if we need more info for this issue

FYI @massimocGH @eugeniagunhouse

williamoliveira commented 1 year ago

Error I get when trying to use ENUM:

$ sequelize $* db:migrate

Sequelize CLI [Node: 18.18.2, CLI: 6.6.2, ORM: 6.35.1]

Loaded configuration file "src/core/dbSequelize/config/database.js".
Using environment "development".
== 20231025150800-create-auth-history: migrating =======

ERROR: at or near "do": syntax error
ERROR DETAIL: source SQL:
DO 'BEGIN CREATE TYPE "public"."enum_auth_history_event" AS ENUM(''auth'', ''password_change''); EXCEPTION WHEN duplicate_object THEN null; END'
^

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.