1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

Code formatting with prettier, change eslint config for the server

This commit is contained in:
Maksim Eltyshev 2019-11-05 18:01:42 +05:00
parent bc87c1d883
commit 7a3805e64c
191 changed files with 4321 additions and 2880 deletions

View file

@ -1,7 +1,8 @@
const config = require('./knexfile');
const knex = require('knex')(config);
(async function () {
const knex = require('knex')(config); // eslint-disable-line import/order
(async () => {
try {
const exists = await knex.schema.hasTable(config.migrations.tableName);

View file

@ -2,14 +2,14 @@ const path = require('path');
const _ = require('lodash');
require('dotenv').config({
path: path.resolve(__dirname, '../.env')
path: path.resolve(__dirname, '../.env'),
});
module.exports = {
client: 'pg',
connection: process.env.DATABASE_URL,
migrations: {
tableName: 'migration'
tableName: 'migration',
},
wrapIdentifier: (value, origImpl) => origImpl(_.snakeCase(value))
wrapIdentifier: (value, origImpl) => origImpl(_.snakeCase(value)),
};

View file

@ -1,4 +1,4 @@
module.exports.up = knex => knex.raw(`
module.exports.up = (knex) => knex.raw(`
CREATE SEQUENCE next_id_seq;
CREATE FUNCTION next_id(OUT id BIGINT) AS $$
@ -19,7 +19,7 @@ module.exports.up = knex => knex.raw(`
$$ LANGUAGE PLPGSQL;
`);
module.exports.down = knex => knex.raw(`
module.exports.down = (knex) => knex.raw(`
DROP SEQUENCE next_id_seq;
DROP FUNCTION next_id(OUT id BIGINT);

View file

@ -1,22 +1,21 @@
module.exports.up = knex =>
knex.schema.createTable('archive', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('archive', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.text('from_model').notNullable();
table.bigInteger('original_record_id').notNullable();
table.json('original_record').notNullable();
table.text('from_model').notNullable();
table.bigInteger('original_record_id').notNullable();
table.json('original_record').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.unique(['from_model', 'original_record_id']);
});
table.unique(['from_model', 'original_record_id']);
});
module.exports.down = knex => knex.schema.dropTable('archive');
module.exports.down = (knex) => knex.schema.dropTable('archive');

View file

@ -1,25 +1,24 @@
module.exports.up = knex =>
knex.schema
.createTable('user', table => {
/* Columns */
module.exports.up = (knex) => knex.schema
.createTable('user', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.text('email').notNullable();
table.text('password').notNullable();
table.boolean('is_admin').notNullable();
table.text('name').notNullable();
table.text('avatar');
table.text('email').notNullable();
table.text('password').notNullable();
table.boolean('is_admin').notNullable();
table.text('name').notNullable();
table.text('avatar');
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('deleted_at', true);
})
.raw(
'ALTER TABLE "user" ADD CONSTRAINT "user_email_unique" EXCLUDE ("email" WITH =) WHERE ("deleted_at" IS NULL)'
);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('deleted_at', true);
})
.raw(
'ALTER TABLE "user" ADD CONSTRAINT "user_email_unique" EXCLUDE ("email" WITH =) WHERE ("deleted_at" IS NULL)',
);
module.exports.down = knex => knex.schema.dropTable('user');
module.exports.down = (knex) => knex.schema.dropTable('user');

View file

@ -1,16 +1,15 @@
module.exports.up = knex =>
knex.schema.createTable('project', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('project', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.text('name').notNullable();
table.text('name').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
});
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
});
module.exports.down = knex => knex.schema.dropTable('project');
module.exports.down = (knex) => knex.schema.dropTable('project');

View file

@ -1,22 +1,21 @@
module.exports.up = knex =>
knex.schema.createTable('project_membership', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('project_membership', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('project_id').notNullable();
table.bigInteger('user_id').notNullable();
table.bigInteger('project_id').notNullable();
table.bigInteger('user_id').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.unique(['project_id', 'user_id']);
table.index('user_id');
});
table.unique(['project_id', 'user_id']);
table.index('user_id');
});
module.exports.down = knex => knex.schema.dropTable('project_membership');
module.exports.down = (knex) => knex.schema.dropTable('project_membership');

View file

@ -1,24 +1,23 @@
module.exports.up = knex =>
knex.schema.createTable('board', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('board', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('project_id').notNullable();
table.bigInteger('project_id').notNullable();
table.specificType('position', 'double precision').notNullable();
table.text('name').notNullable();
table.specificType('position', 'double precision').notNullable();
table.text('name').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.index('project_id');
table.index('position');
});
table.index('project_id');
table.index('position');
});
module.exports.down = knex => knex.schema.dropTable('board');
module.exports.down = (knex) => knex.schema.dropTable('board');

View file

@ -1,24 +1,23 @@
module.exports.up = knex =>
knex.schema.createTable('list', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('list', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('board_id').notNullable();
table.bigInteger('board_id').notNullable();
table.specificType('position', 'double precision').notNullable();
table.text('name').notNullable();
table.specificType('position', 'double precision').notNullable();
table.text('name').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.index('board_id');
table.index('position');
});
table.index('board_id');
table.index('position');
});
module.exports.down = knex => knex.schema.dropTable('list');
module.exports.down = (knex) => knex.schema.dropTable('list');

View file

@ -1,23 +1,22 @@
module.exports.up = knex =>
knex.schema.createTable('label', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('label', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('board_id').notNullable();
table.bigInteger('board_id').notNullable();
table.text('name');
table.text('color').notNullable();
table.text('name');
table.text('color').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.index('board_id');
});
table.index('board_id');
});
module.exports.down = knex => knex.schema.dropTable('label');
module.exports.down = (knex) => knex.schema.dropTable('label');

View file

@ -1,28 +1,27 @@
module.exports.up = knex =>
knex.schema.createTable('card', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('card', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('list_id').notNullable();
table.bigInteger('board_id').notNullable();
table.bigInteger('list_id').notNullable();
table.bigInteger('board_id').notNullable();
table.specificType('position', 'double precision').notNullable();
table.text('name').notNullable();
table.text('description');
table.timestamp('dueDate', true);
table.jsonb('timer');
table.specificType('position', 'double precision').notNullable();
table.text('name').notNullable();
table.text('description');
table.timestamp('dueDate', true);
table.jsonb('timer');
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.index('list_id');
table.index('position');
});
table.index('list_id');
table.index('position');
});
module.exports.down = knex => knex.schema.dropTable('card');
module.exports.down = (knex) => knex.schema.dropTable('card');

View file

@ -1,24 +1,23 @@
module.exports.up = knex =>
knex.schema.createTable('card_subscription', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('card_subscription', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('card_id').notNullable();
table.bigInteger('user_id').notNullable();
table.bigInteger('card_id').notNullable();
table.bigInteger('user_id').notNullable();
table.boolean('is_permanent').notNullable();
table.boolean('is_permanent').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.unique(['card_id', 'user_id']);
table.index('user_id');
});
table.unique(['card_id', 'user_id']);
table.index('user_id');
});
module.exports.down = knex => knex.schema.dropTable('card_subscription');
module.exports.down = (knex) => knex.schema.dropTable('card_subscription');

View file

@ -1,22 +1,21 @@
module.exports.up = knex =>
knex.schema.createTable('card_membership', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('card_membership', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('card_id').notNullable();
table.bigInteger('user_id').notNullable();
table.bigInteger('card_id').notNullable();
table.bigInteger('user_id').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.unique(['card_id', 'user_id']);
table.index('user_id');
});
table.unique(['card_id', 'user_id']);
table.index('user_id');
});
module.exports.down = knex => knex.schema.dropTable('card_membership');
module.exports.down = (knex) => knex.schema.dropTable('card_membership');

View file

@ -1,22 +1,21 @@
module.exports.up = knex =>
knex.schema.createTable('card_label', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('card_label', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('card_id').notNullable();
table.bigInteger('label_id').notNullable();
table.bigInteger('card_id').notNullable();
table.bigInteger('label_id').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.unique(['card_id', 'label_id']);
table.index('label_id');
});
table.unique(['card_id', 'label_id']);
table.index('label_id');
});
module.exports.down = knex => knex.schema.dropTable('card_label');
module.exports.down = (knex) => knex.schema.dropTable('card_label');

View file

@ -1,23 +1,22 @@
module.exports.up = knex =>
knex.schema.createTable('task', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('task', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('card_id').notNullable();
table.bigInteger('card_id').notNullable();
table.text('name').notNullable();
table.boolean('is_completed').notNullable();
table.text('name').notNullable();
table.boolean('is_completed').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.index('card_id');
});
table.index('card_id');
});
module.exports.down = knex => knex.schema.dropTable('task');
module.exports.down = (knex) => knex.schema.dropTable('task');

View file

@ -1,24 +1,23 @@
module.exports.up = knex =>
knex.schema.createTable('action', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('action', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('card_id').notNullable();
table.bigInteger('user_id').notNullable();
table.bigInteger('card_id').notNullable();
table.bigInteger('user_id').notNullable();
table.text('type').notNullable();
table.jsonb('data').notNullable();
table.text('type').notNullable();
table.jsonb('data').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.index('card_id');
});
table.index('card_id');
});
module.exports.down = knex => knex.schema.dropTable('action');
module.exports.down = (knex) => knex.schema.dropTable('action');

View file

@ -1,27 +1,26 @@
module.exports.up = knex =>
knex.schema.createTable('notification', table => {
/* Columns */
module.exports.up = (knex) => knex.schema.createTable('notification', (table) => {
/* Columns */
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table
.bigInteger('id')
.primary()
.defaultTo(knex.raw('next_id()'));
table.bigInteger('user_id').notNullable();
table.bigInteger('action_id').notNullable();
table.bigInteger('card_id').notNullable();
table.bigInteger('user_id').notNullable();
table.bigInteger('action_id').notNullable();
table.bigInteger('card_id').notNullable();
table.boolean('is_read').notNullable();
table.boolean('is_read').notNullable();
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
table.timestamp('created_at', true);
table.timestamp('updated_at', true);
/* Indexes */
/* Indexes */
table.index('user_id');
table.index('action_id');
table.index('card_id');
table.index('is_read');
});
table.index('user_id');
table.index('action_id');
table.index('card_id');
table.index('is_read');
});
module.exports.down = knex => knex.schema.dropTable('notification');
module.exports.down = (knex) => knex.schema.dropTable('notification');

View file

@ -1,6 +1,6 @@
const bcrypt = require('bcrypt');
exports.seed = function(knex) {
exports.seed = (knex) => {
const date = new Date().toUTCString();
return knex('user').insert({
@ -9,6 +9,6 @@ exports.seed = function(knex) {
isAdmin: true,
name: 'Demo Demo',
createdAt: date,
updatedAt: date
updatedAt: date,
});
};