Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jhthorsen/dbix-class-schema-diff

Diff two schemas, regardless of version numbers
https://github.com/jhthorsen/dbix-class-schema-diff

Last synced: 27 days ago
JSON representation

Diff two schemas, regardless of version numbers

Awesome Lists containing this project

README

        

NAME
DBIx::Class::Schema::Diff - Diff two schemas, regardless of version
numbers

VERSION
0.00

DESCRIPTION
Is there a project which can check out two tags/commits from
git and make a diff between the two schemas? So instead of
having the version information in the database, I would like
to A) make a diff between database and the current checked out
version from the repo B) make a diff between two git-versions.

SYNOPSIS
From a module:

use DBIx::Class::Schema::Diff;

my $diff = DBIx::Class::Schema::Diff->new(
from => $dsn,
to => 'MyApp::Schema',
databases => ['SQLite'],
);

# write "diff", "to" and "from" to disk
$diff->diff_ddl($directory) or die $diff->errstr;
$diff->to_ddl($directory) or die $diff->errstr;
$diff->from_ddl($directory) or die $diff->errstr;

Using the script:

$ schema-diff.pl \
--from 'DBI:SQLite:t/db/one.sqlite' \
--to 'dbi:Pg:dbname=somedatabase&user&pass' \
--write-from \
--write-to \
--output - \
;

ATTRIBUTES
from
Any source (module name, dbh or dsn) which has the old version of the
schema. This attribute can coerce. See DBIx::Class::Schema::Diff::Types
for details.

to
Any source (module name, dbh or dsn) which has the new version of the
schema. This attribute can coerce. See DBIx::Class::Schema::Diff::Types
for details.

databases
Which SQL language the output files should be in.

errstr
Holds the last error if any as a string.

METHODS
diff_ddl
$bool = $self->diff_ddl($directory, \%args);
$bool = $self->diff_ddl(\$text, \%args);

Will write the diff (one file per each type in "databases") between
"from" and "to" to a selected $directory. %args is passed on to
SQL::Translator::Diff::new(), but "output_db", "source_schema" and
"target_schema" is set by this method.

Will write DDL to $text if given as a scalar reference. (This might not
make much sense, if you have more than one type defined in "databases").

from_ddl
to_ddl
$bool = $self->from_ddl($directory);
$bool = $self->from_ddl(\$text);
$bool = $self->to_ddl($directory);
$bool = $self->to_ddl(\$text);

Will write "from" or "to" schemas as DDL to the given directory, with
all the languages defined in "databases".

Will write DDL to $text if it is given as a scalar reference. (This
might not make much sense, if you have more than one type defined in
"databases".

COPYRIGHT & LICENSE
This library is free software. You can redistribute it and/or modify it
under the same terms as Perl itself.

AUTHOR
Jan Henning Thorsen "jhthorsen at cpan.org"