Skip to content

Commit

Permalink
timeoff-management v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
João Pires committed Mar 7, 2021
1 parent c5cfd2c commit 83532d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 35 deletions.
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
# This is the base for our build step container
FROM node:10-alpine AS base
FROM node:12-alpine AS base

# Install dependencies
RUN apk add --no-cache git

# Create and change to workdir
WORKDIR /app
RUN git clone --branch 1.0.0 https://github.com/timeoff-management/application.git timeoff-management
RUN git clone --branch 1.1.1 https://github.com/timeoff-management/application.git timeoff-management

WORKDIR /app/timeoff-management

# Install dependencies
RUN npm install mysql && npm install --production

# 20190118-chnage-type-value-for-api-token.js isn't compatible with mariadb. A better solution 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/

# This is our runtime container
FROM alpine:3.10
FROM alpine:3.12

# Install npm
RUN apk add --update nodejs npm
Expand All @@ -24,11 +28,7 @@ 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"]
35 changes: 8 additions & 27 deletions scripts/20190118-chnage-type-value-for-api-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,22 @@
const models = require("../lib/model/db");

module.exports = {
up: function(queryInterface, Sequelize) {
return queryInterface.describeTable("Companies").then(attributes => {
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"]))
return queryInterface.changeColumn(
"Companies",
"integration_api_token",
models.Company.attributes.integration_api_token
);
});
},

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

0 comments on commit 83532d3

Please sign in to comment.