-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sergey Peshkov
committed
Jan 29, 2020
1 parent
ed40ab2
commit 1607362
Showing
3 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |