mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
[model] migrations setup
This commit is contained in:
parent
c6a5895de7
commit
69a50fea4f
26 changed files with 426 additions and 337 deletions
|
@ -4,6 +4,7 @@ const moment = require('moment')
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const event = sequelize.define('event', {
|
const event = sequelize.define('event', {
|
||||||
id: {
|
id: {
|
||||||
|
allowNull: false,
|
||||||
type: DataTypes.INTEGER,
|
type: DataTypes.INTEGER,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
autoIncrement: true
|
autoIncrement: true
|
||||||
|
|
|
@ -7,7 +7,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||||
index: true,
|
index: true,
|
||||||
primaryKey: true
|
primaryKey: true
|
||||||
},
|
},
|
||||||
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false }
|
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false },
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
tag.associate = function (models) {
|
tag.associate = function (models) {
|
||||||
|
|
|
@ -185,11 +185,10 @@ async function setupQuestionnaire(is_docker, db) {
|
||||||
return answers
|
return answers
|
||||||
}
|
}
|
||||||
|
|
||||||
async function upgrade (options) {
|
async function run_migrations (db_conf) {
|
||||||
const Umzug = require('umzug')
|
const Umzug = require('umzug')
|
||||||
const Sequelize = require('sequelize')
|
const Sequelize = require('sequelize')
|
||||||
const config = require('config')
|
const db = new Sequelize(db_conf)
|
||||||
const db = new Sequelize(config.db)
|
|
||||||
const umzug = new Umzug({
|
const umzug = new Umzug({
|
||||||
storage: 'sequelize',
|
storage: 'sequelize',
|
||||||
storageOptions: { sequelize: db },
|
storageOptions: { sequelize: db },
|
||||||
|
@ -217,13 +216,15 @@ async function start (options) {
|
||||||
If this is your first run use 'gancio setup --config <CONFIG_FILE.json>' `)
|
If this is your first run use 'gancio setup --config <CONFIG_FILE.json>' `)
|
||||||
process.exit(-1)
|
process.exit(-1)
|
||||||
}
|
}
|
||||||
await upgrade(options)
|
const config = require('config')
|
||||||
|
await run_migrations(config.db)
|
||||||
require('./index')
|
require('./index')
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setup (options) {
|
async function setup (options) {
|
||||||
consola.info(`You're going to setup gancio on this machine.`)
|
consola.info(`You're going to setup gancio on this machine.`)
|
||||||
const config = await setupQuestionnaire(options.docker, options.db)
|
const config = await setupQuestionnaire(options.docker, options.db)
|
||||||
|
await run_migrations(config.db)
|
||||||
const ret = await firstrun.setup(config, options.config)
|
const ret = await firstrun.setup(config, options.config)
|
||||||
if (!ret) process.exit(-1)
|
if (!ret) process.exit(-1)
|
||||||
if (options.docker) {
|
if (options.docker) {
|
||||||
|
|
|
@ -27,18 +27,11 @@ module.exports = {
|
||||||
|
|
||||||
// sync db
|
// sync db
|
||||||
const db = require('./api/models')
|
const db = require('./api/models')
|
||||||
|
const users = await db.user.findAll()
|
||||||
try {
|
if (users.length) {
|
||||||
await db.user.findAll()
|
|
||||||
consola.warn(` ⚠ Non empty db! Please move your current db elsewhere than retry.`)
|
consola.warn(` ⚠ Non empty db! Please move your current db elsewhere than retry.`)
|
||||||
return false
|
return false
|
||||||
} catch (e) { }
|
}
|
||||||
|
|
||||||
consola.info(`Create tables schema`)
|
|
||||||
await db.sequelize.sync().catch(e => {
|
|
||||||
consola.error(' ⚠ ️ Error creating tables', e)
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
|
|
||||||
// create admin user
|
// create admin user
|
||||||
consola.info('Create admin user', admin)
|
consola.info('Create admin user', admin)
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('users', 'username', {
|
|
||||||
type: Sequelize.STRING,
|
|
||||||
index: true,
|
|
||||||
allowNull: false,
|
|
||||||
defaultValue: ''
|
|
||||||
})
|
|
||||||
/*
|
|
||||||
Add altering commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('users', 'display_name', {
|
|
||||||
type: Sequelize.STRING
|
|
||||||
})
|
|
||||||
/*
|
|
||||||
Add altering commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('users', 'rsa', {
|
|
||||||
type: Sequelize.JSON
|
|
||||||
})
|
|
||||||
/*
|
|
||||||
Add altering commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('users', 'followers', {
|
|
||||||
type: Sequelize.JSON
|
|
||||||
})
|
|
||||||
/*
|
|
||||||
Add altering commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('events', 'likes', {
|
|
||||||
type: Sequelize.JSON,
|
|
||||||
defaultValue: []
|
|
||||||
})
|
|
||||||
/*
|
|
||||||
Add altering commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('events', 'boost', {
|
|
||||||
type: Sequelize.JSON,
|
|
||||||
defaultValue: []
|
|
||||||
})
|
|
||||||
|
|
||||||
/*
|
|
||||||
Add altering commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('users', 'settings', {
|
|
||||||
type: Sequelize.JSON,
|
|
||||||
defaultValue: {}
|
|
||||||
})
|
|
||||||
/*
|
|
||||||
Add altering commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return queryInterface.addColumn('events', 'recurrent', {
|
|
||||||
type: Sequelize.JSON
|
|
||||||
})
|
|
||||||
|
|
||||||
/*
|
|
||||||
Add altering commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
|
|
||||||
*/
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,47 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface, Sequelize) => {
|
|
||||||
return Promise.all([
|
|
||||||
queryInterface.removeColumn('users', 'followers'),
|
|
||||||
queryInterface.createTable('user_followers', {
|
|
||||||
userId: {
|
|
||||||
type: Sequelize.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: 'users',
|
|
||||||
key: 'id'
|
|
||||||
},
|
|
||||||
primaryKey: true,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
fedUserApId: {
|
|
||||||
primaryKey: true,
|
|
||||||
type: Sequelize.STRING,
|
|
||||||
references: {
|
|
||||||
model: 'fed_users',
|
|
||||||
key: 'ap_id'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
createdAt: { type: Sequelize.DATE, allowNull: false },
|
|
||||||
updatedAt: { type: Sequelize.DATE, allowNull: false }
|
|
||||||
})
|
|
||||||
])},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
return Promise.all([
|
|
||||||
queryInterface.addColumn(
|
|
||||||
'users', 'followers', {
|
|
||||||
type: JSON,
|
|
||||||
defaultValue: []
|
|
||||||
}),
|
|
||||||
queryInterface.dropTable('user_followers')
|
|
||||||
])
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -1,56 +0,0 @@
|
||||||
'use strict';
|
|
||||||
const { notification: Notification } = require('../api/models')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: async (queryInterface, Sequelize) => {
|
|
||||||
|
|
||||||
// remove all notifications
|
|
||||||
await Notification.destroy({where: []})
|
|
||||||
|
|
||||||
// add `action` field to notification
|
|
||||||
try {
|
|
||||||
await queryInterface.addColumn('notifications', 'action', {
|
|
||||||
type: Sequelize.ENUM,
|
|
||||||
values: ['Create', 'Update', 'Delete']
|
|
||||||
})
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
// modify values of `type` field
|
|
||||||
try {
|
|
||||||
await queryInterface.removeColumn('notifications', 'type').catch()
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
try {
|
|
||||||
await queryInterface.addColumn('notifications', 'type', {
|
|
||||||
type: Sequelize.ENUM,
|
|
||||||
values: ['mail', 'admin_email', 'ap']
|
|
||||||
})
|
|
||||||
} catch {}
|
|
||||||
|
|
||||||
await queryInterface.addIndex('notifications', {
|
|
||||||
unique: true,
|
|
||||||
fields: ['action', 'type' ]
|
|
||||||
})
|
|
||||||
|
|
||||||
// add AP notifications
|
|
||||||
await Notification.create({ action: 'Create', type: 'ap', filters: { is_visible: true } })
|
|
||||||
await Notification.create({ action: 'Update', type: 'ap', filters: { is_visible: true } })
|
|
||||||
await Notification.create({ action: 'Delete', type: 'ap', filters: { is_visible: true } })
|
|
||||||
|
|
||||||
// send anon events via email to admin
|
|
||||||
await Notification.create({ action: 'Create', type: 'admin_email', filters: { is_visible: false } })
|
|
||||||
|
|
||||||
return true
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
|
||||||
return Promise.resolve()
|
|
||||||
/*
|
|
||||||
Add reverting commands here.
|
|
||||||
Return a promise to correctly handle asynchronicity.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
return queryInterface.dropTable('users');
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
};
|
|
31
server/migrations/20191025133803-tags.js
Normal file
31
server/migrations/20191025133803-tags.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('tags',
|
||||||
|
{
|
||||||
|
tag: {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
index: true,
|
||||||
|
primaryKey: true
|
||||||
|
},
|
||||||
|
weigth: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
defaultValue: 0, allowNull: false
|
||||||
|
},
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('tags')
|
||||||
|
}
|
||||||
|
};
|
34
server/migrations/20191025134318-places.js
Normal file
34
server/migrations/20191025134318-places.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('places',
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
allowNull: false,
|
||||||
|
autoIncrement: true,
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
unique: true,
|
||||||
|
index: true,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
address: Sequelize.STRING,
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('places')
|
||||||
|
}
|
||||||
|
}
|
29
server/migrations/20191025135631-settings.js
Normal file
29
server/migrations/20191025135631-settings.js
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('settings',
|
||||||
|
{
|
||||||
|
key: {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
primaryKey: true,
|
||||||
|
allowNull: false,
|
||||||
|
index: true
|
||||||
|
},
|
||||||
|
value: Sequelize.JSON,
|
||||||
|
is_secret: Sequelize.BOOLEAN,
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('settings')
|
||||||
|
}
|
||||||
|
};
|
48
server/migrations/20191025141447-users.js
Normal file
48
server/migrations/20191025141447-users.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('users',
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
allowNull: false,
|
||||||
|
autoIncrement: true,
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
unique: { msg: 'error.nick_taken' },
|
||||||
|
index: true,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
display_name: Sequelize.STRING,
|
||||||
|
settings: Sequelize.JSON,
|
||||||
|
email: {
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
unique: { msg: 'error.email_taken' },
|
||||||
|
index: true,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
description: Sequelize.TEXT,
|
||||||
|
password: Sequelize.STRING,
|
||||||
|
recover_code: Sequelize.STRING,
|
||||||
|
is_admin: Sequelize.BOOLEAN,
|
||||||
|
is_active: Sequelize.BOOLEAN,
|
||||||
|
rsa: Sequelize.JSON,
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('users');
|
||||||
|
}
|
||||||
|
};
|
63
server/migrations/20191025142724-events.js
Normal file
63
server/migrations/20191025142724-events.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('events',
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true
|
||||||
|
},
|
||||||
|
title: Sequelize.STRING,
|
||||||
|
slug: Sequelize.STRING,
|
||||||
|
description: Sequelize.TEXT,
|
||||||
|
multidate: Sequelize.BOOLEAN,
|
||||||
|
start_datetime: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
index: true
|
||||||
|
},
|
||||||
|
end_datetime: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
index: true
|
||||||
|
},
|
||||||
|
image_path: Sequelize.STRING,
|
||||||
|
is_visible: Sequelize.BOOLEAN,
|
||||||
|
recurrent: Sequelize.JSON,
|
||||||
|
// parent: Sequelize.INTEGER
|
||||||
|
likes: { type: Sequelize.JSON, defaultValue: [] },
|
||||||
|
boost: { type: Sequelize.JSON, defaultValue: [] },
|
||||||
|
placeId: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
references: {
|
||||||
|
model: 'places',
|
||||||
|
key: 'id',
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'SET NULL',
|
||||||
|
},
|
||||||
|
userId: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
references: {
|
||||||
|
model: 'users',
|
||||||
|
key: 'id',
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'SET NULL',
|
||||||
|
},
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('events')
|
||||||
|
}
|
||||||
|
};
|
41
server/migrations/20191025143411-comments.js
Normal file
41
server/migrations/20191025143411-comments.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('comments',
|
||||||
|
{
|
||||||
|
id: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true
|
||||||
|
},
|
||||||
|
activitypub_id: {
|
||||||
|
type: Sequelize.STRING(18),
|
||||||
|
index: true,
|
||||||
|
unique: true
|
||||||
|
},
|
||||||
|
eventId: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
references: {
|
||||||
|
model: 'events',
|
||||||
|
key: 'id',
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'SET NULL',
|
||||||
|
},
|
||||||
|
data: Sequelize.JSON,
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('comments')
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,4 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.createTable('fed_users', {
|
return queryInterface.createTable('fed_users', {
|
||||||
|
@ -17,9 +18,9 @@ module.exports = {
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
type: Sequelize.DATE
|
type: Sequelize.DATE
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
},
|
},
|
||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('fed_users');
|
return queryInterface.dropTable('fed_users')
|
||||||
}
|
}
|
||||||
};
|
};
|
35
server/migrations/20191025145516-followers.js
Normal file
35
server/migrations/20191025145516-followers.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('user_followers', {
|
||||||
|
userId: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
references: {
|
||||||
|
model: 'users',
|
||||||
|
key: 'id'
|
||||||
|
},
|
||||||
|
primaryKey: true,
|
||||||
|
allowNull: false,
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'CASCADE'
|
||||||
|
},
|
||||||
|
fedUserApId: {
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
references: {
|
||||||
|
model: 'fed_users',
|
||||||
|
key: 'ap_id'
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'CASCADE'
|
||||||
|
},
|
||||||
|
createdAt: { type: Sequelize.DATE, allowNull: false },
|
||||||
|
updatedAt: { type: Sequelize.DATE, allowNull: false }
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('user_followers')
|
||||||
|
}
|
||||||
|
};
|
36
server/migrations/20191025150200-notifications.js
Normal file
36
server/migrations/20191025150200-notifications.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('notifications',{
|
||||||
|
id: {
|
||||||
|
allowNull: false,
|
||||||
|
autoIncrement: true,
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
},
|
||||||
|
filters: Sequelize.JSON,
|
||||||
|
email: Sequelize.STRING,
|
||||||
|
remove_code: Sequelize.STRING,
|
||||||
|
action: {
|
||||||
|
type: Sequelize.ENUM,
|
||||||
|
values: ['Create', 'Update', 'Delete']
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: Sequelize.ENUM,
|
||||||
|
values: ['mail', 'admin_email', 'ap']
|
||||||
|
},
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('notifications')
|
||||||
|
}
|
||||||
|
};
|
15
server/migrations/20191025150506-notifications_index.js
Normal file
15
server/migrations/20191025150506-notifications_index.js
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.addIndex('notifications', {
|
||||||
|
unique: true,
|
||||||
|
fields: ['action', 'type']
|
||||||
|
}).catch(e => {})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.removeIndex('notifications',
|
||||||
|
['actions', 'type'])
|
||||||
|
}
|
||||||
|
};
|
40
server/migrations/20191025151459-event_tags.js
Normal file
40
server/migrations/20191025151459-event_tags.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('event_tags', {
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
eventId: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
references: {
|
||||||
|
model: 'events',
|
||||||
|
key: 'id',
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
},
|
||||||
|
tagTag: {
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.STRING,
|
||||||
|
references: {
|
||||||
|
model: 'tags',
|
||||||
|
key: 'tag',
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('event_tags')
|
||||||
|
}
|
||||||
|
};
|
40
server/migrations/20191025152224-event_notifications.js
Normal file
40
server/migrations/20191025152224-event_notifications.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.createTable('event_notifications', {
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
eventId: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
references: {
|
||||||
|
model: 'events',
|
||||||
|
key: 'id',
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
},
|
||||||
|
notificationId: {
|
||||||
|
primaryKey: true,
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
references: {
|
||||||
|
model: 'notifications',
|
||||||
|
key: 'id',
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'CASCADE',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface, Sequelize) => {
|
||||||
|
return queryInterface.dropTable('event_notifications')
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue