-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #493 from bluewave-labs/rewrite-migrations
Rewrite migrations
- Loading branch information
Showing
33 changed files
with
775 additions
and
806 deletions.
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
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,74 @@ | ||
'use strict'; | ||
|
||
const settings = require('./../config/settings'); | ||
|
||
const TABLE_NAME = 'users'; // Define the table name | ||
|
||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
await queryInterface.createTable(TABLE_NAME, { | ||
id: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
name: { | ||
type: Sequelize.STRING(50), | ||
allowNull: false, | ||
}, | ||
surname: { | ||
type: Sequelize.STRING(50), | ||
allowNull: true, | ||
}, | ||
email: { | ||
type: Sequelize.STRING(100), | ||
allowNull: false, | ||
unique: true, | ||
}, | ||
password: { | ||
type: Sequelize.STRING(100), | ||
allowNull: false, | ||
}, | ||
role: { | ||
type: Sequelize.ENUM, | ||
values: settings.user.roleEnum, | ||
defaultValue: settings.user.role.admin, | ||
allowNull: false, | ||
}, | ||
picture:{ | ||
type: Sequelize.TEXT, | ||
allowNull: true, | ||
}, | ||
createdAt: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"), | ||
}, | ||
}, { transaction }); | ||
|
||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
// Drop the guide_logs table | ||
await queryInterface.dropTable(TABLE_NAME, { transaction }); | ||
|
||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
} | ||
}; |
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,68 @@ | ||
'use strict'; | ||
|
||
const TABLE_NAME = 'helper_link'; // Define the table name | ||
|
||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
await queryInterface.createTable(TABLE_NAME, { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
title: { | ||
type: Sequelize.STRING(255), | ||
allowNull: false, | ||
}, | ||
headerBackgroundColor: { | ||
type: Sequelize.STRING(7), | ||
allowNull: false, | ||
defaultValue : '#F8F9F8' | ||
}, | ||
linkFontColor: { | ||
type: Sequelize.STRING(7), | ||
allowNull: false, | ||
defaultValue : '#344054' | ||
}, | ||
iconColor: { | ||
type: Sequelize.STRING(7), | ||
allowNull: false, | ||
defaultValue: '#7F56D9' | ||
}, | ||
createdBy: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: 'users', | ||
key: 'id' | ||
} | ||
} | ||
}, { transaction }); | ||
|
||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
// Drop the guide_logs table | ||
await queryInterface.dropTable(TABLE_NAME, { transaction }); | ||
|
||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
} | ||
}; |
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,68 @@ | ||
'use strict'; | ||
|
||
const TABLE_NAME = 'link'; // Define the table name | ||
|
||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
await queryInterface.createTable(TABLE_NAME, { | ||
id: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
title: { | ||
type: Sequelize.STRING(255), | ||
allowNull: false, | ||
}, | ||
url: { | ||
type: Sequelize.STRING(255), | ||
allowNull: false, | ||
}, | ||
order: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
defaultValue: 1, | ||
}, | ||
target: { | ||
type: Sequelize.BOOLEAN, | ||
defaultValue: true, | ||
allowNull: true, | ||
}, | ||
helperId: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: "helper_link", | ||
key: "id", | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE", | ||
}, | ||
}, { transaction }); | ||
|
||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
// Drop the guide_logs table | ||
await queryInterface.dropTable(TABLE_NAME, { transaction }); | ||
|
||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
} | ||
}; |
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,67 @@ | ||
'use strict'; | ||
|
||
const TABLE_NAME = 'tokens'; // Define the table name | ||
|
||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
await queryInterface.createTable(TABLE_NAME, { | ||
id: { | ||
type: Sequelize.INTEGER, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
allowNull: false, | ||
}, | ||
token: { | ||
type: Sequelize.STRING(500), | ||
allowNull: false, | ||
}, | ||
userId: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: 'users', | ||
key: 'id' | ||
} | ||
}, | ||
type: { | ||
type: Sequelize.STRING(10), | ||
allowNull: false, | ||
}, | ||
expiresAt: { | ||
type: Sequelize.DATE, | ||
allowNull: true, | ||
}, | ||
createdAt: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.literal("CURRENT_TIMESTAMP"), | ||
}, | ||
|
||
}, { transaction }); | ||
|
||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
// Drop the guide_logs table | ||
await queryInterface.dropTable(TABLE_NAME, { transaction }); | ||
|
||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
} | ||
}; |
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,83 @@ | ||
'use strict'; | ||
|
||
const TABLE_NAME = 'banners'; // Define the table name | ||
|
||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
await queryInterface.createTable(TABLE_NAME, { | ||
id: { | ||
allowNull: false, | ||
autoIncrement: true, | ||
primaryKey: true, | ||
type: Sequelize.INTEGER | ||
}, | ||
closeButtonAction: { | ||
type: Sequelize.STRING(255), | ||
allowNull: false | ||
}, | ||
repetitionType: { | ||
type: Sequelize.STRING(255), | ||
allowNull: false, | ||
defaultValue: 'show only once' | ||
}, | ||
position: { | ||
type: Sequelize.STRING(255), | ||
allowNull: false | ||
}, | ||
url: { | ||
type: Sequelize.STRING(255), | ||
allowNull: true | ||
}, | ||
fontColor: { | ||
type: Sequelize.STRING(255), | ||
allowNull: false, | ||
defaultValue: "#FFFFFF" | ||
}, | ||
backgroundColor: { | ||
type: Sequelize.STRING(255), | ||
allowNull: false, | ||
defaultValue: "#FFFFFF" | ||
}, | ||
bannerText: { | ||
type: Sequelize.STRING(255), | ||
allowNull: false, | ||
defaultValue: "" | ||
}, | ||
actionUrl: { | ||
type: Sequelize.STRING(255), | ||
allowNull: true | ||
}, | ||
createdBy: { | ||
type: Sequelize.INTEGER, | ||
allowNull: false, | ||
references: { | ||
model: 'users', | ||
key: 'id' | ||
} | ||
} | ||
}, { transaction }); | ||
|
||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
}, | ||
|
||
down: async (queryInterface, Sequelize) => { | ||
const transaction = await queryInterface.sequelize.transaction(); | ||
try { | ||
await queryInterface.dropTable(TABLE_NAME, { transaction }); | ||
// Commit the transaction | ||
await transaction.commit(); | ||
} catch (error) { | ||
// Rollback the transaction in case of an error | ||
await transaction.rollback(); | ||
throw error; | ||
} | ||
} | ||
}; |
Oops, something went wrong.