Goodvidio Backend Product Engineer
Treating databases as another piece of code.
name VARCHAR(20)
owner VARCHAR(20)
species VARCHAR(20)
first_name VARCHAR(20)
last_name VARCHAR(20)
owner VARCHAR(20)
species VARCHAR(20)
{
...
is_subscribed: true
...
},
{
...
is_subscribed: true
...
},
{
...
is_subscribed: true
...
}
{
...
is_subscribed: false
...
},
{
...
is_subscribed: false
...
},
{
...
is_subscribed: false
...
}
module.exports = {
up: function(queryInterface, Sequelize) {
queryInterface.createTable(
'nameOfTheNewTable',
{
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
createdAt: {
type: Sequelize.DATE
},
updatedAt: {
type: Sequelize.DATE
},
attr1: Sequelize.STRING
},
{
engine: 'MYISAM', // default: 'InnoDB'
charset: 'latin1' // default: null
}
)
},
down: function(queryInterface, Sequelize) {
queryInterface.dropTable('nameOfTheNewTable');
}
}
module.exports = {
up: function(queryInterface, Sequelize) {
request.post({
url: 'https://some.rest.api/v1/users',
json: true,
body: {
name: 'Kostas Bariotis',
email: 'kbariotis@goodvid.io'
}
}, function(err, resp, body) {
/* ... */
});
},
down: function(queryInterface, Sequelize) {
request.delete({
url: 'https://some.rest.api/v1/users',
json: true,
body: {
email: 'kbariotis@goodvid.io'
}
}, function(err, resp, body) {
/* ... */
});
}
}
$ ./scripts/migrate
$ ./scripts/migrate up 1.0
$ ./scripts/migrate down 0.8
module.exports = {
up: function(queryInterface, Sequelize) {
queryInterface.createTable(
'nameOfTheNewTable',
{
...
}
);
queryInterface.createTable(
'nameOfAnotherTable',
{
...
}
);
},
down: function(queryInterface, Sequelize) {
/* ... */
}
}
module.exports = {
up: function(queryInterface, Sequelize) {
queryInterface.addField(
'nameOfTheNewTable',
{
name: Sequelize.STRING
}
)
},
down: function(queryInterface, Sequelize) {
queryInterface.removeField('nameOfTheNewTable', 'name');
}
}
Production
v1.0
Stage
v1.5
Local Dev Env
v2.0 - Feature #154