Navigation Menu

Skip to content

Commit

Permalink
svn diff --diff-cmd is slick! Case and whitespace insensitive! :)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhannah committed Oct 21, 2009
1 parent 2e0ba95 commit 255c894
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/Module/Install/DiffCheck.pm
Expand Up @@ -14,7 +14,7 @@ Add statements like these to your Module::Install generated Makefile.PL:
'Model/mysqldump.pl root SuperSecret', 'Model/mysqldump.pl root SuperSecret',
], ],
diff_commands => [ diff_commands => [
'svn diff Model', 'svn diff --diff-cmd diff -x "-i -b -u" Model',
], ],
ignore_lines => [ ignore_lines => [
qr/ *#/, # Ignore comments qr/ *#/, # Ignore comments
Expand All @@ -24,20 +24,24 @@ Add statements like these to your Module::Install generated Makefile.PL:
); );
That's it. Each C<before_diff_commands> is executed, then each C<diff_commands> That's it. Each C<before_diff_commands> is executed, then each C<diff_commands>
is executed and any diff output lines that don't match an C<ignore_lines> regex cause is executed. Any diff output lines that don't match an C<ignore_lines> regex cause
a fatal error. a fatal error.
We use L<DBIx::Class::Schema::Loader>, mysqldump, and Subversion, but you should
be able to use any version control system, RDBMS, and ORM(s) that make you happy.
And/or you could diff other files that have nothing to do with databases.
=head1 DESCRIPTION =head1 DESCRIPTION
If you use a version control system to deploy your applications you might find If you use a version control system to deploy your applications you might find
this module useful. this module useful.
=head1 How we check our database schemas =head2 How we check our database schemas
Here, I describe the specifics of how we use this where I work, in case Here, I describe the specifics of how we use this where I work, in case
you find this practical example illustrative. you find this practical example illustrative.
Where I work we commit all our database schemas into our We commit all our database schemas into our
version control system. Every time we deploy a specific release it is critical that version control system. Every time we deploy a specific release it is critical that
the RDBMS schema on that server exactly matches the schema in our version control system. the RDBMS schema on that server exactly matches the schema in our version control system.
New tables may have been introduced, tables may have been New tables may have been introduced, tables may have been
Expand All @@ -50,7 +54,7 @@ repository.
(L<DBIx::Class::Schema::Loader> C<make_schema_at> is slick. With 5 lines of code, you can (L<DBIx::Class::Schema::Loader> C<make_schema_at> is slick. With 5 lines of code, you can
flush an entire database into a static Schema/ directory. C<svn diff> shows us what, flush an entire database into a static Schema/ directory. C<svn diff> shows us what,
if anything, has changed. See the POD for that module.) if anything, has changed.)
Similarly, C<mysqldump> output (or whatever utility dumps C<CREATE TABLE> SQL out of your Similarly, C<mysqldump> output (or whatever utility dumps C<CREATE TABLE> SQL out of your
database) added to our SVN repository lets us run C<svn diff> and see everything that changed. database) added to our SVN repository lets us run C<svn diff> and see everything that changed.
Expand All @@ -74,6 +78,7 @@ part(s) of the C<diff_cmd> results were considered fatal.
This module will not help you if you want to manage your schema versions down to This module will not help you if you want to manage your schema versions down to
individual "ALTER TABLE" statements which transform one tag to another tag. individual "ALTER TABLE" statements which transform one tag to another tag.
(Perhaps L<DBIx::Class::Schema::Versioned> could help you with that level of granularity?) (Perhaps L<DBIx::Class::Schema::Versioned> could help you with that level of granularity?)
We don't get that fancy where I work.
=head1 METHODS =head1 METHODS
Expand Down

0 comments on commit 255c894

Please sign in to comment.