A
A
Alexander Koshelev2018-08-15 21:53:41
PostgreSQL
Alexander Koshelev, 2018-08-15 21:53:41

How to create a table in postgres in a specific schema using sequelize?

Good evening everyone! Can you please tell me how to create a table in the schema I need? The code below creates a table in the default public schema, if someone advises me to read the Sequelize documentation, then it is always in front of me, there I figured out how to remove the automatically added 2 fields, and registered timestamps, I also searched everything in Google and nothing I managed to find it (I’m not saying that it doesn’t exist 100%, but I couldn’t find it), please help!

const Sequelize = require('sequelize');
const db = new Sequelize('postgres://лог:пасс@localhost:5434/bd');

const auth = db.define('taba', {
  username: Sequelize.TEXT,
  password: Sequelize.TEXT
  //email: Sequelize.TEXT
}, {
  timestamps: false,
});

db.sync({force: true}).then(()=>{
  auth.create({
    username: 'test',
    password: 'test',
    email: 'test'
  })
})

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-08-15
@Xandr24

...if anyone advises me to read the Sequelize documentation...

I advise. They write (scroll down to the list of options) that the property is called schema.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question