Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
node: true,
'jest/globals': true,
},
plugins: ['jest'],
extends: [
'airbnb-base',
],
Expand Down
78 changes: 36 additions & 42 deletions migrations/20210517131034-create_application_datasets_manytomany.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,42 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
return queryInterface.createTable(
'application_datasets', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
dataset_id: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'data_sets',
key: 'id',
},
onUpdate: 'cascade',
onDelete: 'cascade',
},
application_id: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'applications',
key: 'id',
},
onUpdate: 'cascade',
onDelete: 'cascade',
},
created_at: {
allowNull: false,
type: Sequelize.DATE,
up: async (queryInterface, Sequelize) => queryInterface.createTable(
'application_datasets', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
dataset_id: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'data_sets',
key: 'id',
},
updated_at: {
allowNull: false,
type: Sequelize.DATE,
onUpdate: 'cascade',
onDelete: 'cascade',
},
application_id: {
type: Sequelize.INTEGER,
allowNull: false,
references: {
model: 'applications',
key: 'id',
},
onUpdate: 'cascade',
onDelete: 'cascade',
},
created_at: {
allowNull: false,
type: Sequelize.DATE,
},
updated_at: {
allowNull: false,
type: Sequelize.DATE,
},
)
},
},
),

down: async (queryInterface, Sequelize) => {
return queryInterface.dropTable('application_datasets');
}
down: async (queryInterface, Sequelize) => queryInterface.dropTable('application_datasets'),
};
10 changes: 4 additions & 6 deletions migrations/20210517133143-delete_application_dataset_id.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.removeConstraint(
'applications',
'applications_ibfk_1',
{transaction}
'applications_ibfk_1',
{ transaction },
);
await queryInterface.removeColumn(
'applications',
'dataset_id',
transaction,
);
return transaction.commit();
}catch (error) {
} catch (error) {
await transaction.rollback();
throw error;
}
Expand Down Expand Up @@ -44,5 +42,5 @@ module.exports = {
await transaction.rollback();
throw error;
}
}
},
};
82 changes: 41 additions & 41 deletions migrations/20210625183225-create-locations.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
module.exports = {

up(queryInterface, Sequelize) {
return queryInterface.createTable(
'locations', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
application_id: {
type: Sequelize.INTEGER,
allowNull: true,
references: {
model: 'applications',
key: 'id',
},
onUpdate: 'cascade',
onDelete: 'cascade',
},
longitude: {
type: Sequelize.INTEGER,
allowNull: false,
},
latitude: {
type: Sequelize.INTEGER,
allowNull: false,
},
leave_at: {
type: Sequelize.DATE,
allowNull: true,
defaultValue: null,
},
created_at: {
type: Sequelize.DATE,
allowNull: false,
},
updated_at: {
type: Sequelize.DATE,
allowNull: false,
},
deleted_at: {
type: Sequelize.DATE,
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
application_id: {
type: Sequelize.INTEGER,
allowNull: true,
references: {
model: 'applications',
key: 'id',
},
onUpdate: 'cascade',
onDelete: 'cascade',
},
longitude: {
type: Sequelize.INTEGER,
allowNull: false,
},
latitude: {
type: Sequelize.INTEGER,
allowNull: false,
},
leave_at: {
type: Sequelize.DATE,
allowNull: true,
defaultValue: null,
},
created_at: {
type: Sequelize.DATE,
allowNull: false,
},
updated_at: {
type: Sequelize.DATE,
allowNull: false,
},
deleted_at: {
type: Sequelize.DATE,
},
},
},
);
},
down(queryInterface, Sequelize) {
Expand Down
16 changes: 7 additions & 9 deletions migrations/20210706131303-user-application-one-to-many.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use strict';

module.exports = {
up: async (queryInterface, Sequelize) => {
const transaction = await queryInterface.sequelize.transaction();
try {
await queryInterface.addColumn(
'applications',
'user_id',{
'user_id', {
type: Sequelize.INTEGER,
transaction
transaction,
},
);
await queryInterface.addConstraint('applications', {
Expand All @@ -33,18 +31,18 @@ module.exports = {
try {
await queryInterface.removeConstraint(
'applications',
'applications_ibfk_2',
{transaction}
'applications_ibfk_2',
{ transaction },
);
await queryInterface.removeColumn(
'applications',
'user_id',
transaction,
);
return transaction.commit();
}catch (error) {
} catch (error) {
await transaction.rollback();
throw error;
}
}
};
},
};
Loading