* Global search scaffold * Add search preview text * Add generic fallback for preview text in search * fixup! Add generic fallback for preview text in search * Add more tweaks * fixup! Add more tweaks * Fix an issue with criteria * fixup! Fix an issue with criteria * fixup! fixup! Fix an issue with criteria * fixup! fixup! fixup! Fix an issue with criteria * Fix an issue with priority filter * fixup! Fix an issue with priority filter * Add sortable pins * fixup! Add sortable pins * Make options collapsed by default * Tweak UI * Add tests * Add translations * Add more translations * fixup! Add more translations * Add minor tweaks
78 lines
2.3 KiB
JavaScript
78 lines
2.3 KiB
JavaScript
'use strict';
|
|
|
|
const { safeCreateTable, safeAddIndex } = require('../utils/migration-utils');
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await safeCreateTable(queryInterface, 'views', {
|
|
id: {
|
|
type: Sequelize.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true,
|
|
allowNull: false,
|
|
},
|
|
uid: {
|
|
type: Sequelize.STRING,
|
|
allowNull: false,
|
|
unique: true,
|
|
},
|
|
name: {
|
|
type: Sequelize.STRING,
|
|
allowNull: false,
|
|
},
|
|
user_id: {
|
|
type: Sequelize.INTEGER,
|
|
allowNull: false,
|
|
references: {
|
|
model: 'users',
|
|
key: 'id',
|
|
},
|
|
onDelete: 'CASCADE',
|
|
},
|
|
search_query: {
|
|
type: Sequelize.STRING,
|
|
allowNull: true,
|
|
},
|
|
filters: {
|
|
type: Sequelize.TEXT,
|
|
allowNull: true,
|
|
comment: 'JSON array of entity type filters',
|
|
},
|
|
priority: {
|
|
type: Sequelize.STRING,
|
|
allowNull: true,
|
|
},
|
|
due: {
|
|
type: Sequelize.STRING,
|
|
allowNull: true,
|
|
},
|
|
is_pinned: {
|
|
type: Sequelize.BOOLEAN,
|
|
allowNull: false,
|
|
defaultValue: false,
|
|
},
|
|
created_at: {
|
|
type: Sequelize.DATE,
|
|
allowNull: false,
|
|
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
|
|
},
|
|
updated_at: {
|
|
type: Sequelize.DATE,
|
|
allowNull: false,
|
|
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
|
|
},
|
|
});
|
|
|
|
await safeAddIndex(queryInterface, 'views', ['user_id'], {
|
|
name: 'views_user_id_index',
|
|
});
|
|
|
|
await safeAddIndex(queryInterface, 'views', ['user_id', 'is_pinned'], {
|
|
name: 'views_user_pinned_index',
|
|
});
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.dropTable('views');
|
|
},
|
|
};
|