App-JESP
view release on metacpan or search on metacpan
lib/App/JESP.pm view on Meta::CPAN
...
{ "id":"a_backfill_script", "file": "path/to/executable/file.sh" }
...
]
}
See L<APP::JESP::Driver#apply_script> to see what environment the script is being run in. Note that the script
needs to be executable by the current user to be detected as a script.
=head1 COMPATIBILITY
Compatibility of the meta-schema with SQLite, MySQL and PostgreSQL is guaranteed through automated testing.
To see which versions are actually tested, look at the CI build:
L<https://travis-ci.org/jeteve/App-JESP/>
=head1 DRIVERS
This comes with the following built-in drivers:
=head2 SQLite
Just in case. Note that your patches will be executed in the same connection
this uses to manage the metadata.
=head2 mysql
This will use the `mysql` executable on the disk (will look for it in PATH)
to execute your patches, exactly like you would do on the command line.
=head2 Pg
This will use a new connection to the Database to execute the patches.
This is to allow you using BEGIN ; COMMIT; to make your patch transactional
without colliding with the Meta data management transaction.
=head2 Your own driver
Should you want to write your own driver, simply extend L<App::JESP::Driver>
and implement any method you like (most likely you will want apply_sql).
To use your driver, simply give its class to the constuctor:
my $jesp = App::JESP->new({ .., driver_class => 'My::App::JESP::Driver::SpecialDB' });
Or if you prefer to build an instance yourself:
my $jesp;
$jesp = App::JESP->new({ .., driver => My::App::JESP::Driver::SpecialDB->new({ jesp => $jesp, ... ) });
=head1 MOTIVATIONS & DESIGN
Over the years as a developer, I have used at least three ways of managing SQL patches.
The ad-hoc way with a hand-rolled system which is painful to re-implement,
the L<DBIx::Class::Migration> way which I didn't like at all, and more recently
L<App::Sqitch> which I sort of like.
All these systems somehow just manage to do the job, but unless they are very complicated (there
are no limits to hand-rolled complications..) they all fail to provide a sensible
way for a team of developers to work on database schema changes at the same time.
So I decided the world needs yet another SQL patch management system that
does what my team and I really really want.
Here are some design principles this package is attempting to implement:
=over
=item Write your own SQL
No funny SQL generated from code here. By nature, any ORM will always lag behind its
target DBs' features. This means that counting on software to generate SQL statement from
your ORM classes will always prevent you from truly using the full power of your DB of choice.
With App::JESP, you have to write your own SQL for your DB, and this is a good thing.
=item No version numbers
App::JESP simply keeps track of which ones of your named patches are applied to the DB.
Your DB version is just that: The subset of patches that were applied to it. This participates
in allowing several developers to work on different parts of the DB in parallel.
=item No fuss patch ordering
The order in which patches are applied is important. But it is not important
to the point of enforcing exactly the same order on every DB the patches are deployed to.
App::JESP applies the named patches in the order it finds them in the plan, only taking
into account the ones that have not been applied yet. This allows developer to work
on their development DB and easily merge patches from other developers.
=item JSON Based
This is the 21st century, and I feel like I shouldn't invent my own file format.
This uses JSON like everything else.
=item Simple but complex things allowed.
You will find no complex feature in App::JESP, and we pledge to keep the meta schema
simple, to allow for easy repairs if things go wrong.
=item Programmable
It's great to have a convenient command line tool to work and deploy patches, but maybe
your development process, or your code layout is a bit different. If you use L<App::JESP>
from Perl, it should be easy to embed and run it yourself.
=item What about reverting?
Your live DB is not the place to test your changes. Your DB at <My Software> Version N should
be compatible with Code at <My Software> Version N-1. You are responsible for testing that.
We'll probably implement reverting in the future, but for now we assume you
know what you're doing when you patch your DB.
=back
=head1 METHODS
=head2 install
Installs or upgrades the JESP meta tables in the database. This is idempotent.
Note that the JESP meta table(s) will be all prefixed by B<$this->prefix()>.
( run in 1.066 second using v1.01-cache-2.11-cpan-39bf76dae61 )