Skip to content

ignore on init #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 8, 2015
Merged

ignore on init #301

merged 3 commits into from
Sep 8, 2015

Conversation

guydou
Copy link
Contributor

@guydou guydou commented Sep 2, 2015

I wanted to solve the case you are running your migration on existing code.

The migration files can be used either to reproduce env or to deploy changes on existing env.

Running on existing env that was not created using db-migrate will not work since it tries to create tables that already exist.

In order for the migration to run on existed env you should create files that are marked as init, these files will not be used if the flag --ignore-on-init is set on up

Currently I implemented it only on sql files

In this commit on create of SQL files, the user can create out of
templates of files that if a ignore_on_init is set to true on db-migrate
up the content of the SQL file will be ignored
" */",
"exports.setup = function(options, seedLink) {",
" dbm = options.dbmigrate;",
" ignoreOnInit = dbm.getInstance().internals.argv['ignore-on-init']",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this is not a good way to implement this. Creating a new instance of the whole migration framework within a migration is really to much. You can store the ignore-on.init within the options parameter which gets supplied here. See https://github.com/db-migrate/node-db-migrate/blob/master/api.js#L67

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Tobias,

Thanks for your comment,

I totally agree with you, I changed it.

On Wed, Sep 2, 2015 at 6:45 PM, Tobias Gurtzick [email protected]
wrote:

In lib/migration.js
#301 (comment)
:

  • "var dbm;",
  • "var type;",
  • "var seed;",
  • "var fs = require('fs');",
  • "var path = require('path');",
  • "var ignoreOnInit = false;",
  • "",
  • "/**",
  • " * We receive the dbmigrate dependency from dbmigrate initially.",
  • " * This enables us to not have to rely on NODE_PATH.",
  • " */",
  • "exports.setup = function(options, seedLink) {",
  • " dbm = options.dbmigrate;",
  • " ignoreOnInit = dbm.getInstance().internals.argv['ignore-on-init']",

Actually this is not a good way to implement this. Creating a new instance
of the whole migration framework within a migration is really to much. You
can store the ignore-on.init within the options parameter which gets
supplied here. See
https://github.com/db-migrate/node-db-migrate/blob/master/api.js#L67


Reply to this email directly or view it on GitHub
https://github.com/db-migrate/node-db-migrate/pull/301/files#r38548393.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thank you. I think I will take time to review this tomorrow. I think the test and documentation are missing right now. But I will give you feedback as soon as I get to it.

instead of loading the DBM framework on every run
wzrdtales added a commit that referenced this pull request Sep 8, 2015
[Feature] pass through flag "ignore on init", to ignore specific migrations while initialization migrations.
@wzrdtales wzrdtales merged commit 99753e8 into db-migrate:master Sep 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants