Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
João Pires committed Mar 12, 2020
1 parent 794a1a6 commit 93ca636
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ WORKDIR /app/timeoff-management
# Copy files from first stage
COPY --from=base /app/timeoff-management/ /app/timeoff-management

# 20190118-chnage-type-value-for-api-token.js isn't compatible with mariadb. A fixed version is used to replace it
# Issue comment: https://github.com/timeoff-management/timeoff-management-application/issues/329#issuecomment-488327844
COPY scripts/20190118-chnage-type-value-for-api-token.js /app/timeoff-management/migrations/

ADD docker-entrypoint.sh /docker-entrypoint.sh

EXPOSE 3000
ENTRYPOINT ["sh","/docker-entrypoint.sh"]
# ENTRYPOINT ["sh","/docker-entrypoint.sh"]
43 changes: 43 additions & 0 deletions scripts/20190118-chnage-type-value-for-api-token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"use strict";

const models = require("../lib/model/db");

module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.describeTable("Companies").then(attributes => {
if (attributes.integration_api_token.type === "UUID") {
return 1;
}

return (
queryInterface
// Create Temp Compaies based on current model definitiom
.createTable("Companies_backup", models.Company.attributes)
.then(() =>
queryInterface.sequelize.query("SET FOREIGN_KEY_CHECKS=0;")
)
.then(() =>
queryInterface.sequelize.query(
"INSERT INTO `Companies_backup` (`id`,`name`,`country`,`start_of_new_year`,`createdAt`,`updatedAt`,share_all_absences,ldap_auth_enabled,ldap_auth_config,`date_format`,`company_wide_message`,`mode`,`timezone`,`integration_api_token`,`integration_api_enabled`,`carry_over`) SELECT `id`,`name`,`country`,`start_of_new_year`,`createdAt`,`updatedAt`,share_all_absences,ldap_auth_enabled,ldap_auth_config,`date_format`,`company_wide_message`,`mode`,`timezone`,`integration_api_token`,`integration_api_enabled`,`carry_over` FROM `" +
models.Company.tableName +
"`"
)
)
.then(() => queryInterface.dropTable(models.Company.tableName))
.then(() =>
queryInterface.renameTable(
"Companies_backup",
models.Company.tableName
)
)
.then(() => queryInterface.sequelize.query("SET FOREIGN_KEY_CHECKS=1;"))
.then(() => queryInterface.addIndex(models.Company.tableName, ["id"]))
);
});
},

down: function(queryInterface, Sequelize) {
// No way back!
return Promise.resolve();
}
};

0 comments on commit 93ca636

Please sign in to comment.