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

Cannot migrate non-public schema in postgres #490

Open
evantahler opened this issue Jun 14, 2022 · 6 comments
Open

Cannot migrate non-public schema in postgres #490

evantahler opened this issue Jun 14, 2022 · 6 comments

Comments

@evantahler
Copy link
Member

evantahler commented Jun 14, 2022

Adding schema: "foo" to the config does not create tables in the proper schema. The SequelizeMeta table is in the proper schema, but none of the user-generated tables are.

@evantahler
Copy link
Member Author

Answer: You will need both searchPath, dialectOptions, and schema in your config (from sequelize/sequelize#10875). schema is where the SequelizeMeta table will be, and dialectOptions.prependSearchPath and searchPath are about where the tables go:

{
      autoMigrate: true,
      logging: false,
      dialect: dialect as Dialect,
      port: parseInt(port),
      database: database,
      schema: "foo", // <- HERE
      searchPath: "foo", // <- HERE
      host: host,
      username: username,
      password: password,
      models: [join(__dirname, "..", "models")],
      migrations: [join(__dirname, "..", "migrations")],
      migrationLogLevel: "info",
      dialectOptions: { 
        prependSearchPath: true, // <- HERE
      },
}

@evantahler
Copy link
Member Author

@nholmes3 can you give this a try? If it works, can you add something about this to the readme?

Thanks!

@nholmes3
Copy link

@nholmes3 can you give this a try? If it works, can you add something about this to the readme?

Thanks!

Hey @evantahler , these configuration options are already present in the readme. It is actually a bug in the sequelize code that causes this problem. I have created a PR over in that project that should fix the underlying problem.

I was just curious if the patch code referenced in #488 could still be used as an effective workaround in the meantime. Based on your comments there, it seems some additional development/problem solving might be required to get that code back up and usable as a workaround.

It would definitely be nice to have something to use while waiting on my PR in sequelize to go through the release cycle, but it seems that updating this code might take just as long.

I would be interested in collaborating if you have any immediate thoughts.

@nholmes3
Copy link

nholmes3 commented Jun 27, 2022

Hey @evantahler I have successfully merged the fix for this issue into the v6 branch of the sequelize project which should make this issue unnecessary for the latest sequelize version.

Before we completely resolve this, would you be interested in connecting on LinkedIn? I am not sure how else to reach out to you, and Brian mentioned that I should discuss upgrading the sequelize package in Grouparoo with you in order to fix this problem. It would be great to talk this over with you you! Thanks :)

@evantahler
Copy link
Member Author

Sorry for the delay, I'm on vacation 🌴

Awesome work merging the fix into Sequelize!

Sure, let's connect on LinkedIn - I'm https://linkedin.com/in/evantahler and we'll take it from there.

@nholmes3
Copy link

Hey @evantahler no worries!

I haven't managed to reach you on LinkedIn so I am falling back to this thread. I hope that's okay.

To elaborate further on my above comment, I was able to get a fix for the sequelize bug included in version 6.21.1. Grouparoo currently uses version 6.17.0 .

I know that Grouparoo is no longer under active development, but I was wondering if it is at all possible to release one final version that upgrades sequelize to 6.21.1. This would allow for Grouparoo users to be able to provide custom schema names in the database that Grouparoo uses. I believe that this functionality is crucial for using Grouparoo effectively.

If there is anything that I can do to help with this process, I am more than happy to contribute in any way possible.

Thanks for your consideration!

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