Skip to content

Commit

Permalink
feat(general): campaigns added
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Peshkov committed Jan 29, 2020
1 parent ed40ab2 commit 1607362
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 1 deletion.
48 changes: 48 additions & 0 deletions migrations/20200129112157-create-campaigns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
up: (queryInterface, Sequelize) => queryInterface.createTable('campaigns', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
name: {
type: Sequelize.STRING,
allowNull: false
},
url: {
type: Sequelize.STRING,
allowNull: false,
unique: true
},
active: {
type: Sequelize.BOOLEAN,
allowNull: false,
default: true
},
description_short: {
type: Sequelize.TEXT,
allowNull: false
},
description_long: {
type: Sequelize.TEXT,
allowNull: false
},
activate_user: {
type: Sequelize.BOOLEAN,
allowNull: false,
default: false
},
created_at: {
allowNull: false,
type: Sequelize.DATE
},
updated_at: {
allowNull: false,
type: Sequelize.DATE
}
}),
down: (queryInterface) => {
return queryInterface.dropTable('campaigns');
}
};
55 changes: 55 additions & 0 deletions models/Campaign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { Sequelize, sequelize } = require('../lib/sequelize');
const config = require('../config');

const Campaign = sequelize.define('campaign', {
name: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: '',
validate: {
notEmpty: { msg: 'Name should be set.' },
}
},
url: {
type: Sequelize.STRING,
allowNull: false,
defaultValue: '',
validate: {
notEmpty: { msg: 'Name should be set.' },
},
unique: true
},
active: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true
},
description_short: {
type: Sequelize.TEXT,
allowNull: false,
defaultValue: '',
validate: {
notEmpty: { msg: 'Description should be set.' },
}
},
description_long: {
type: Sequelize.TEXT,
allowNull: false,
defaultValue: '',
validate: {
notEmpty: { msg: 'Description should be set.' },
}
},
activate_user: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true
},
}, {
underscored: true,
tableName: 'campaigns',
createdAt: 'created_at',
updatedAt: 'updated_at',
});

module.exports = Campaign;
4 changes: 3 additions & 1 deletion models/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const User = require('./User');
const Campaign = require('./Campaign');

module.exports = {
User
User,
Campaign
};

0 comments on commit 1607362

Please sign in to comment.