Files
outline/server/migrations/20180115021837-add-drafts.js
Tom Moor a411e08f1f chore: Address code quality findings (#11960)
* chore: Address code quality findings

* Round 2, quality findings

* fix: Add fallback for MediaQueryList.addEventListener in test env

The jsdom test environment doesn't implement addEventListener on
MediaQueryList. Prefer addEventListener but fall back to the
deprecated addListener when unavailable.
2026-04-04 16:11:10 -04:00

36 lines
1011 B
JavaScript

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("documents", "publishedAt", {
type: Sequelize.DATE,
allowNull: true,
});
const [documents] = await queryInterface.sequelize.query(
`SELECT * FROM documents`
);
for (const document of documents) {
await queryInterface.sequelize.query(`
update documents
set "publishedAt" = '${new Date(document.createdAt).toISOString()}'
where id = '${document.id}'
`);
}
await queryInterface.removeIndex("documents", ["id", "atlasId"]);
await queryInterface.addIndex("documents", [
"id",
"atlasId",
"publishedAt",
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn("documents", "publishedAt");
await queryInterface.removeIndex("documents", [
"id",
"atlasId",
"publishedAt",
]);
await queryInterface.addIndex("documents", ["id", "atlasId"]);
},
};