30 Oct 2013 08:31:50 UTC
- Distribution: GitDDL
- Module version: 0.03
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (3)
- Testers (1072 / 46 / 0)
- KwaliteeBus factor: 0
- 27.55% Coverage
- License: perl_5
- Perl: v5.8.1
- Download (31.43KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:2 non-PAUSE users
- COPYRIGHT AND LICENSE
GitDDL - database migration utility for git managed sql
my $gd = GitDDL->new( work_tree => '/path/to/project', # git working directory ddl_file => 'sql/schema_ddl.sql', dsn => ['dbi:mysql:my_project', 'root', ''], ); # checking whether the database version matchs ddl_file version or not. $gd->check_version; # getting database version my $db_version = $gd->database_version; # getting ddl version my $ddl_version = $gd->ddl_version; # upgrade database $gd->upgrade_database; # deploy ddl $gd->deploy;
This is database migration helper module for users who manage database schema version by single .sql file in git repository.
By using this module, you can deploy .sql to database, check sql version between database and .sql file, make diff between them, and apply alter table to database.
my $gd = GitDDL->new( work_tree => '/path/to/project', # git working directory ddl_file => 'sql/schema_ddl.sql', dsn => ['dbi:mysql:my_project', 'root', ''], );
Create GitDDL object. Available options are:
work_tree => 'Str' (Required)
Git working tree path includes target ddl file.
ddl_file => 'Str' (Required)
ddl file (.sql file) path in repository.
If ddl file located at /repos/project/sql/schema.sql and work_tree root is /repos/project, then this option should be sql/schema.sql
dsn => 'ArrayRef' (Required)
DSN parameter that pass to DBI module.
version_table => 'Str' (optional)
database table name that contains its git commit version. (default: git_ddl_version)
sql_filter => 'CodeRef' (optional)
CodeRef for filtering sql content. It is invoked only in
diff()method. (default: do nothing)
Compare versions latest ddl sql and database, and return true when both version is same.
Otherwise return false, which means database is not latest. To upgrade database to latest, see upgrade_database method described below.
Return git commit hash indicates database's schema.
Return git commit hash indicates ddl file.
Just deploy ddl_file schema to database. This method is designed for initial database setup. But database should be created previously.
Show sql differences between ddl file and database. This method is useful for dry-run checking before upgrade_database.
Upgrade database schema to latest ddl schema.
Daisuke Murase <email@example.com>
Copyright (c) 2012 Daisuke Murase. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
|s||Focus search bar|
|?||Bring up this help dialog|
|g p||Go to pull requests|
|g i||go to github issues (only if github is preferred repository)|
|g a||Go to author|
|g c||Go to changes|
|g i||Go to issues|
|g d||Go to dist|
|g r||Go to repository/SCM|
|g s||Go to source|
|g b||Go to file browse|