Code Monkey home page Code Monkey logo

mnesia_migrate's Introduction

mnesia_migrate

A tool to upgrade/downgrade schema and migrate data between different versions of mnesia.

Build Status

Installation

  • run make deps if you are using erlang.mk

Usage

  • Add contents of priv/sys.config to your application's sys.config or use this config in your release.
  • Use forward slash in defining directory names in sys.config
  • To use apply_downgrades/1, use a number in the argument which will downgrade that many revisions from currently applied head.
  • To enable print statements of library, add {debug, true} in sys.config
  • Run detect_revision_sequence_conflicts() to get a list of revision id where there is a fork in the revision tree.

License

MIT License

mnesia_migrate's People

Contributors

keeper575 avatar srijan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mnesia_migrate's Issues

Tests are failing in a clean clone

$ make deps
...
$ make eunit SKIP_DEPS=1
 GEN    test-dir
 GEN    eunit
db_migration_tests:8: check_file_creation_test_ (Check Src Dir Exists)...*failed*
in function db_migration_tests:'-check_file_creation_test_/0-fun-0-'/1 (test/db_migration_tests.erl, line 8)
**error:{assertEqual,[{module,db_migration_tests},
              {line,8},
              {expression,"filelib : is_dir ( db_migration : get_migration_source_filepath ( ) )"},
              {expected,true},
              {value,false}]}
  output:<<"">>

db_migration_tests:10: check_file_creation_test_ (Check Beam Dir Exists)...*failed*
in function db_migration_tests:'-check_file_creation_test_/0-fun-2-'/1 (test/db_migration_tests.erl, line 10)
**error:{assertEqual,[{module,db_migration_tests},
              {line,10},
              {expression,"filelib : is_dir ( db_migration : get_migration_beam_filepath ( ) )"},
              {expected,true},
              {value,false}]}
  output:<<"">>

db_migration_tests: check_migration_file_creation_test_ (check revision file creation)...*failed*
in function db_migration_tests:'-check_migration_file_creation_test_/0-fun-0-'/2 (test/db_migration_tests.erl, line 33)
in call from db_migration_tests:'-check_migration_file_creation_test_/0-fun-2-'/0 (test/db_migration_tests.erl, line 33)
**error:{assertEqual,[{module,db_migration_tests},
              {line,33},
              {expression,"filelib : is_file ( Filename )"},
              {expected,true},
              {value,false}]}
  output:<<"Compile file: /home/srijan/workspace/mnesia_migrate/schema.template
schema.template: Warning: Compiled template not saved (need out_dir option)
Base Rev module is ''
New file created "a2436b29c_migration.erl"
">>

db_migration_tests: check_migration_file_creation_test_ (check revision file creation and deletion)...*failed*
in function db_migration_tests:'-check_migration_file_creation_test_/0-fun-3-'/1 (test/db_migration_tests.erl, line 43)
**error:{assertCmd_failed,[{module,db_migration_tests},
                   {line,43},
                   {command,"rm /home/gaurav/project/mnesia_migrate/src/migrations/ad5900fcb_migration.erl"},
                   {expected_status,0},
                   {status,1}]}
  output:<<"Compile file: /home/srijan/workspace/mnesia_migrate/schema.template
Base Rev module is ''
New file created "ad5900fcb_migration.erl"
">>

db_migration_tests: check_database_related_function_test_ (check_applied_head_test_1)...*failed*
in function db_migration:get_applied_head/0 (src/db_migration.erl, line 139)
in call from db_migration_tests:'-check_database_related_function_test_/0-fun-0-'/1 (test/db_migration_tests.erl, line 54)
**error:{badmatch,{aborted,{no_exists,schema_migrations}}}
  output:<<"">>

db_migration_tests: check_db_related_test_ (check_applied_head_test_2)...*failed*
in function db_migration:get_applied_head/0 (src/db_migration.erl, line 139)
in call from db_migration_tests:'-check_db_related_test_/0-fun-0-'/1 (test/db_migration_tests.erl, line 65)
**error:{badmatch,{aborted,{no_exists,schema_migrations}}}
  output:<<"">>

=======================================================
  Failed: 6.  Skipped: 0.  Passed: 5.
erlang.mk:6244: recipe for target 'eunit' failed
make: *** [eunit] Error 2

Maybe auto-search for beam dir

For most applications, beam directory changes when application version changes. Changing sys.config should not be required every time a new version is released.

It might be good to support auto-search in all beam directories.

Discussion on how to detect migrations

There are a few different options:

  1. Write migrations in .erl files at a specified location, and find those files from code.
  2. Ensure that migration beam files are at a specified location, and find them that way.
  3. Ensure that all migration files follow a specific pattern, then find them using code:get_path/0 and filelib:wildcard/1

The problem with option 2 is that it's difficult to specify a location which can be found both in local dev environments and releases.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.