Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #72 from rosart-io/master
Browse files Browse the repository at this point in the history
Runmigration -rev options + mysql null default value fix.
  • Loading branch information
PythonCoderAS authored Jun 17, 2022
2 parents 2b0b460 + b1908f5 commit 1dd07de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bin/makemigration.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ try {
} catch (e) { }

//console.log(path.join(migrationsDir, '_current.json'), JSON.parse(fs.readFileSync(path.join(migrationsDir, '_current.json') )))
let sequelize = require(modelsDir).sequelize;
let sequelize = require(modelsDir).default;

let models = sequelize.models;

Expand Down
8 changes: 4 additions & 4 deletions bin/runmigration.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (options.help)
process.exit(0);
}

const sequelize = require(modelsDir).sequelize;
const sequelize = require(modelsDir).default;
const queryInterface = sequelize.getQueryInterface();

// execute all migration from
Expand All @@ -65,15 +65,15 @@ let migrationFiles = fs.readdirSync(migrationsDir)
})
// sort by revision
.sort( (a, b) => {
let revA = parseInt( path.basename(a).split('-',2)[0]),
revB = parseInt( path.basename(b).split('-',2)[0]);
let revA = parseInt( path.basename(a).split('-',2)[1]),
revB = parseInt( path.basename(b).split('-',2)[1]);
if (revA < revB) return -1;
if (revA > revB) return 1;
return 0;
})
// remove all migrations before fromRevision
.filter((file) => {
let rev = parseInt( path.basename(file).split('-',2)[0]);
let rev = parseInt( path.basename(file).split('-',2)[1]);
return (rev >= fromRevision);
});

Expand Down
6 changes: 5 additions & 1 deletion lib/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ const reverseModels = function(sequelize, models)

if (property === 'defaultValue')
{
let _val = reverseSequelizeDefValueType(attributes[column][property]);
let _val = {}
if (attributes[column][property] != null)
_val = reverseSequelizeDefValueType(attributes[column][property]);
else
_val.notSupported = true;
if (_val.notSupported)
{
log(`[Not supported] Skip defaultValue column of attribute ${model}:${column}`);
Expand Down

0 comments on commit 1dd07de

Please sign in to comment.