Answer the question
In order to leave comments, you need to log in
Migrations for raw requests?
Hello. Tell me please. Base on PostreSQL. I used to use Sequelize, but in migrations I write raw queries
const tableName = 'Roles';
module.exports = {
up: ({ sequelize }) => sequelize.query(`
CREATE TABLE "${tableName}" (
id SERIAL PRIMARY KEY,
name VARCHAR(40) NOT NULL DEFAULT '',
"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TRIGGER "${tableName}UpdateAt"
BEFORE UPDATE ON "${tableName}"
FOR EACH ROW EXECUTE PROCEDURE "updateAtTimestamp"();
INSERT INTO "${tableName}" (name)
VALUES ('admin'), ('trader'), ('dealer'), ('customer');
`),
down: ({ sequelize }) => sequelize.query(`DROP TABLE IF EXISTS "${tableName}";`)
};
Answer the question
In order to leave comments, you need to log in
Why do you need some tool if you write raw queries?
It can still use what the tool gives , and not write queries by hand (why did they set the ORM at all then?)
https://sequelize.org/v5/manual/migrations.html#mi...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question