Skip to content

Commit

Permalink
Merge pull request #459 from strapi/fix/create-user-log
Browse files Browse the repository at this point in the history
Fix postgres and mysql logs user table creation
  • Loading branch information
lauriejim committed Jan 17, 2018
2 parents 8749dc2 + 2c1fd73 commit 832dd16
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,15 @@ module.exports = {
1锔忊儯 EXECUTE THE FOLLOWING SQL QUERY
CREATE TABLE "${tableName}" (
id integer NOT NULL,
id ${Model.client === 'pg' ? 'SERIAL' : 'INT AUTO_INCREMENT'} NOT NULL PRIMARY KEY,
username text,
email text,
provider text,
role text,
"resetPasswordToken" text,
${Model.client === 'pg' ? '"resetPasswordToken"' : 'resetPasswordToken'} text,
password text,
updated_at timestamp with time zone,
created_at timestamp with time zone
updated_at ${Model.client === 'pg' ? 'timestamp with time zone' : 'timestamp'},
created_at ${Model.client === 'pg' ? 'timestamp with time zone' : 'timestamp'}
);
2锔忊儯 RESTART YOUR SERVER
Expand All @@ -300,10 +301,10 @@ CREATE TABLE "${tableName}" (
.then(() => {
const attributes = _.cloneDeep(Model.attributes);
attributes.id = {
type: 'integer'
type: Model.client === 'pg' ? 'integer' : 'int'
};
attributes.updated_at = attributes.created_at = {
type: 'timestamp with time zone'
type: Model.client === 'pg' ? 'timestamp with time zone' : 'timestamp'
};

let commands = '';
Expand All @@ -317,7 +318,7 @@ CREATE TABLE "${tableName}" (
description.type = 'text';
}

commands += `\r\nALTER TABLE "${tableName}" ADD "${attribute}" ${description.type};`;
commands += `\r\nALTER TABLE "${tableName}" ADD ${Model.client === 'pg' ? `"${attribute}"` : `${attribute}`} ${description.type};`;
}

resolve();
Expand Down

0 comments on commit 832dd16

Please sign in to comment.