Skip to content
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

Adding Support for basic DB Migrations #12

Open
isocroft opened this issue Feb 13, 2017 · 0 comments
Open

Adding Support for basic DB Migrations #12

isocroft opened this issue Feb 13, 2017 · 0 comments

Comments

@isocroft
Copy link
Owner

isocroft commented Feb 13, 2017

So, i have come up with a few ideas for adding migrations. Instead of having tables in the DB for marking the when and how of a migration to determine order of migration execution, we simply have a file where the order of definitions equals the order of migrations. you can easily create and delete a migration or add a migration via command line (This will simply add or remove a definition in the migration file).

The definition will be made up of a call to the build static method of DBSchema class. The first argument is the name of the "schema build" (so to speak). It will be a combination of the Model class name and a colon(:) followed by a UNIX timestamp of the current date and time. The second argument will be a closure that return the DB schema as an array.

      DBSchema::build('ChatMessages:1382086394000', function($type){
              return array(
                     'column1' => $type->asId()->int(10),
                     'column2' => $type->text('Okay')
              );
      });

The above block of code will be added using the command below

     $ php jollof make:migration ChatMessages --build

The command above will receive standard input (stdin) for column names and their corresponding types and size. There will be no need to include the table name (as the schema will be automatically bound to the Model class which already has the table name). The command below will run the migration.

       $ php jollof run:migration ChatMessages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant