sequelize / sequelize-typescript

Decorators and some other features for sequelize
MIT License
2.78k stars 280 forks source link

missing dialect on Sequelize #790

Open demsey2 opened 4 years ago

demsey2 commented 4 years ago

Versions

I'm submitting a ... [x] bug report [ ] feature request

Actual behavior: Sequelize doesn't have a Dialect type defined (not String type but Dialect type)

Expected behavior: a specific dialect should be defined

const db = connect();
// this should be possible
db.sequelize.dialect.supports.schemas = true;
ertankara commented 4 years ago

Did you initialize your db, with options that is similar to following?

const sequelize = new Sequelize({
  database: config.DB_DATABASE!,
  username: config.DB_USERNAME!,
  password: config.DB_PASSWORD!,
  dialect: 'mysql',
  models,
  benchmark: false,
  logging: false
})

To actally create your tables run following sequeliize.sync()

To foce update which drops all of the tables and recreates them Becaureful with this one sequelize.sync({ force: true })

demsey2 commented 4 years ago

yes this is how I initialize my db.

I don't have any problems with tables creation my issue is around switching db name in the same connection.

I did a research and it looks like it is possible and to achieve that I need to set that db.sequelize.dialect.supports.schemas = true;

dberardo-com commented 1 year ago

i have come across this post where this option is used but on a model level, not on a db level: https://betterprogramming.pub/cross-database-associations-in-sequelize-orm-2be18091a918

can this help ?

is there also another way to achieve cross-db joins, btw ?