question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

queryInterface.addColumns always adds "public." to the table name for Postgres

See original GitHub issue

Not sure if I’m doing anything wrong, but this is a pretty big blocker for me right now. I need to add a column to an existing table which is in a schema different from “public”.

Simply using the table name throws this error: "relation \"public.mytable\" does not exist"

Adding the schema to the table name throws (this works for addIndex): "relation \"public.default.mytable\" does not exist"

I’ve tried adding a schema property to the options object, like for the createTable method, but it seems to be ignored.

Is there a way to avoid “public” always getting added? I’ve also haven’t seen a way to send arbitrary sql statements to the queryInterface, this way I could just send the “alter table” myself.

sequelize version: 5.19.4

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
allenwu1973commented, Jan 20, 2021

For those who are like me found this from google search, this is duplicate of #11742

It seems like there’s no way to specify a default schema for migrations (won’t work with addColumn), you can however, change all your migrations to specify schema instead

0reactions
github-actions[bot]commented, Nov 30, 2021

This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the “stale” label. 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sequelize migration add "IF NOT EXISTS" to addIndex and ...
If the column you need to add does not exist then call the queryInterface.addColumn function. const tableName = 'your_table_name' ...
Read more >
QueryInterface - Sequelize
Add a new column to a table queryInterface.addColumn('tableA', 'columnC', Sequelize.STRING, { after: 'columnB' // after option is only supported by MySQL }); ...
Read more >
Modifying an existing sequelize migration - DEV Community ‍ ‍
This is a sequelize method queryInterface uses, to add a new column to a table. It takes the column and the name of...
Read more >
Fullstack part13 | Migrations, many-to-many relationships
When defining migrations, it is essential to remember that unlike models, column and table names are written in snake case form: await queryInterface....
Read more >
Active Record Migrations - Rails Edge Guides
This migration adds a table called products with a string column called name and a text column called description . A primary key...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found