Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Daniel Böhmer
Hello DBIC devs and users, escpecially fREW,

I poured some work of mine into a dedicated Perl distribution and think
about
uploading it to CPAN. My hope is to get some feedback from you.

Currently you can find the code only on Github:
https://github.com/dboehmer/DBIx-Class-Schema-CheckVersion

Before uploading it to CPAN in the first place I'd like to know:

- Are there any existing modules doing the same job?

- Before occupying the namespace: Do have any thoughts on the name?

Even after uploading I am interested in:

- bug reports

- feature requests

- patches in form of Github Pull Requests

- ideas how to enable automatic calling of check_version() during
connect()
but still allowing deploying and therefor connecting to any empty DB w/o
check

Here's the story of what the module is about:

I am adopting DBIC::DeploymentHandler in a project I'm currently working
for.
We agreed on having having a check on server startup to see if the
database
has the same version as our schema. It wasn't trivial for me to find out
how
to do that but the result are a few pretty generic lines. You can
inherit
the module from your schema class and call check_version()

I am looking forward to your feedback and releasing the module.

Kind regards
Daniel Böhmer aka DBOEHMER

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Stefan Hornburg (Racke)
On 01/06/2017 01:58 PM, Daniel Böhmer wrote:

> Hello DBIC devs and users, escpecially fREW,
>
> I poured some work of mine into a dedicated Perl distribution and think
> about
> uploading it to CPAN. My hope is to get some feedback from you.
>
> Currently you can find the code only on Github:
> https://github.com/dboehmer/DBIx-Class-Schema-CheckVersion
>
> Before uploading it to CPAN in the first place I'd like to know:
>
> - Are there any existing modules doing the same job?
>
> - Before occupying the namespace: Do have any thoughts on the name?
>
> Even after uploading I am interested in:
>
> - bug reports
>
> - feature requests
>
> - patches in form of Github Pull Requests
>
> - ideas how to enable automatic calling of check_version() during connect()
> but still allowing deploying and therefor connecting to any empty DB w/o
> check
>
> Here's the story of what the module is about:
>
> I am adopting DBIC::DeploymentHandler in a project I'm currently working
> for.
> We agreed on having having a check on server startup to see if the database
> has the same version as our schema. It wasn't trivial for me to find out
> how
> to do that but the result are a few pretty generic lines. You can inherit
> the module from your schema class and call check_version()
>
> I am looking forward to your feedback and releasing the module.
>
> Kind regards
> Daniel Böhmer aka DBOEHMER

Hello Daniel,

we are using DeploymentHandler for all our projects with DBIx::Class.

I'm really fond of it, but it lacks some scripting stuff like querying
the versions and running the prepare and upgrade scripts.

I created a module to support scripting:

https://metacpan.org/pod/DBIx::Class::DeploymentHandler::CLI

I also coded a helper for custom scripts, which are also a fantastic
part of DeploymentHandler, but you can't easily test them right
now. This will be part of a subsequent release.

Regards
        Racke


>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@...


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Andrew Beverley
On Fri, 6 Jan 2017 "Stefan Hornburg (Racke)" wrote:
> we are using DeploymentHandler for all our projects with DBIx::Class.
>
> I'm really fond of it, but it lacks some scripting stuff like querying
> the versions and running the prepare and upgrade scripts.
>
> I created a module to support scripting:
>
> https://metacpan.org/pod/DBIx::Class::DeploymentHandler::CLI

There is also DBIx::Class::Migration to manage versions, preparations,
fixtures etc, which is build on DH. It's a relatively heavyweight
solution, but I use it extensively and it works well.

Andy

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Daniel Böhmer
Hi Andy and Racke,

I know of all the modules you mentioned. Personally I've decided to go
with
App::DH which works fine for me. I don't know the exact differences
though.

However, I don't get what you want to tell me. Is the purpose of my
module already implemented in yours?

To make it exactly clear: My module is not about handling migrations
itself. I just happened to have a software based on a schema managed
with App::DH & DBIC::DeploymentHandler and desired a quick way to
add a version check to my web application.

Maybe I'm missing your point. Then please give me a hint how to
easily add a version check to MyApp.pm when using DBIC::DH::CLI
or DBIC::Migration.

Kind regards
Daniel Böhmer


On 2017-01-06 15:33, Andrew Beverley wrote:

> On Fri, 6 Jan 2017 "Stefan Hornburg (Racke)" wrote:
>> we are using DeploymentHandler for all our projects with DBIx::Class.
>>
>> I'm really fond of it, but it lacks some scripting stuff like querying
>> the versions and running the prepare and upgrade scripts.
>>
>> I created a module to support scripting:
>>
>> https://metacpan.org/pod/DBIx::Class::DeploymentHandler::CLI
>
> There is also DBIx::Class::Migration to manage versions, preparations,
> fixtures etc, which is build on DH. It's a relatively heavyweight
> solution, but I use it extensively and it works well.
>
> Andy
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@...

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Andrew Beverley
On Fri, 06 Jan 2017 Daniel Böhmer <[hidden email]> wrote:
> I know of all the modules you mentioned. Personally I've decided to
> go with App::DH which works fine for me. I don't know the exact differences
> though.
>
> However, I don't get what you want to tell me. Is the purpose of my
> module already implemented in yours?

They are other options to consider when deploying and managing your
schemas with DH. If you've already seen them and they're not for you,
then great.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Mike South
In reply to this post by Daniel Böhmer
Hi Daniel,

One comment I would make is that I think you should pick one word order and stick with it for everything.  Your module on github is named CheckVersion; the perl code inside of it is named VersionCheck.pm; the subroutine is named "check_version"; the environment variable is named "DBIC_SKIP_VERSION_CHECK".

It's weird to me to have a subroutine named with a leading underscore that is designed to be overridden (I'm new to the guts of DBIC components, so if that's normal, ignore my ignorant input).

The naming of those subroutines "database_too_new" and "database_too_old" make them sound like booleans--as if you would be able to do this:

if ($schema->database_too_new) {
# deal with that
}
elsif ( $schema->database_too_old ) {
# deal with that
}

Maybe they should be named "handle_database_too_old" and "handle_database_too_new".  I would also suggest that you actually implement database_too_new and database_too_old and make those available to the user as well.

For example, a user may want to check if the database is too old, and, if so, attempt to apply an update script, and then check again, or something like that, rather than only having the ability to specify a particular subroutine to run in the database-too-old situation.

I very much like your idea of having (what appears to me to be) a clean wrapper that can be called by the user in one function.  Having said that, I'm a relative newcomer to DBIC and I've never used DeploymentHandler, so my input is certainly less informed than it could be.

mike


On Fri, Jan 6, 2017 at 6:58 AM, Daniel Böhmer <[hidden email]> wrote:
Hello DBIC devs and users, escpecially fREW,

I poured some work of mine into a dedicated Perl distribution and think about
uploading it to CPAN. My hope is to get some feedback from you.

Currently you can find the code only on Github:
https://github.com/dboehmer/DBIx-Class-Schema-CheckVersion

Before uploading it to CPAN in the first place I'd like to know:

- Are there any existing modules doing the same job?

- Before occupying the namespace: Do have any thoughts on the name?

Even after uploading I am interested in:

- bug reports

- feature requests

- patches in form of Github Pull Requests

- ideas how to enable automatic calling of check_version() during connect()
but still allowing deploying and therefor connecting to any empty DB w/o check

Here's the story of what the module is about:

I am adopting DBIC::DeploymentHandler in a project I'm currently working for.
We agreed on having having a check on server startup to see if the database
has the same version as our schema. It wasn't trivial for me to find out how
to do that but the result are a few pretty generic lines. You can inherit
the module from your schema class and call check_version()

I am looking forward to your feedback and releasing the module.

Kind regards
Daniel Böhmer aka DBOEHMER

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Matt S Trout-2
In reply to this post by Stefan Hornburg (Racke)
On Fri, Jan 06, 2017 at 03:17:58PM +0100, Stefan Hornburg (Racke) wrote:
> I created a module to support scripting:
>
> https://metacpan.org/pod/DBIx::Class::DeploymentHandler::CLI

I'd love to see any missing features added to the App::DH that I wrote
a few years back unless there's a compelling reason to have two.
 
> I also coded a helper for custom scripts, which are also a fantastic
> part of DeploymentHandler, but you can't easily test them right
> now. This will be part of a subsequent release.

Do please discuss your ideas for that on here - maybe they can be rolled
into DeploymentHandler so they're available to all users thereof?

--
Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue

http://shadowcat.co.uk/blog/matt-s-trout/   http://twitter.com/shadowcat_mst/

Email me now on mst (at) shadowcat.co.uk and let's chat about how our CPAN
commercial support, training and consultancy packages could help your team.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Matt S Trout-2
In reply to this post by Mike South
On Tue, Jan 17, 2017 at 10:20:13PM -0600, Mike South wrote:
> Hi Daniel,
>
> One comment I would make is that I think you should pick one word order and
> stick with it for everything.  Your module on github is named CheckVersion;
> the perl code inside of it is named VersionCheck.pm; the subroutine is
> named "check_version"; the environment variable is named
> "DBIC_SKIP_VERSION_CHECK".

Ah, yes, one of those silly mistakes that's easy to make when you're mid
development.

Definitely worth unifying one way or the other; I'm untroubled as to which.

Should also probably be a way to trigger the version check automatically.

My suggestion would be for the plugin to wrap connection() to take a
version_check (or check_version ;) attribute in the final hashref, plus
a class accessor that provides a default which the attribute overrides if
present.

> Maybe they should be named "handle_database_too_old" and
> "handle_database_too_new".  I would also suggest that you actually
> implement database_too_new and database_too_old and make those available to
> the user as well.

How about on_database_too_new and is_database_too_new as a naming pattern?
 
> I very much like your idea of having (what appears to me to be) a clean
> wrapper that can be called by the user in one function.  Having said that,
> I'm a relative newcomer to DBIC and I've never used DeploymentHandler, so
> my input is certainly less informed than it could be.

If you want to test an API for intuitiveness, a relative newcomer is the
best sort of test case, tbh. It might be important that the implementation
makes sense to me, but where the API and the docs are concerned whether they
make sense to you is almost certainly a better measure of "is this sane?" :)

--
Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue

http://shadowcat.co.uk/blog/matt-s-trout/   http://twitter.com/shadowcat_mst/

Email me now on mst (at) shadowcat.co.uk and let's chat about how our CPAN
commercial support, training and consultancy packages could help your team.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...
Reply | Threaded
Open this post in threaded view
|

Re: Please review my proposed CPAN Module: DBIx-Class-Schema-VersionCheck

Stefan Hornburg (Racke)
In reply to this post by Matt S Trout-2
On 01/24/2017 11:40 PM, Matt S Trout wrote:
> On Fri, Jan 06, 2017 at 03:17:58PM +0100, Stefan Hornburg (Racke) wrote:
>> I created a module to support scripting:
>>
>> https://metacpan.org/pod/DBIx::Class::DeploymentHandler::CLI
>
> I'd love to see any missing features added to the App::DH that I wrote
> a few years back unless there's a compelling reason to have two.
>

OK, I'll check that out ...

>> I also coded a helper for custom scripts, which are also a fantastic
>> part of DeploymentHandler, but you can't easily test them right
>> now. This will be part of a subsequent release.
>
> Do please discuss your ideas for that on here - maybe they can be rolled
> into DeploymentHandler so they're available to all users thereof?
>

Currently I'm working on a larger and complicated migration,
so I'm going through a lot of iterations.

Changing schema and/or custom script, prepare the DH files
and run the upgrade.

So basically I run the following script after resetting the database:

git clean -df sql

./bin/dh-prepare-upgrade

./bin/install-custom --before-sql InvalidValues
./bin/install-custom --before-sql FixDanglingRecords
./bin/install-custom MergeAccounts

./bin/dh-upgrade

InvalidValues, FixDanglingRecords and MergeAccounts are Perl
modules in the Foo::Schema::Upgrades namespace.

I can also run an individual script with

./bin/run-custom MergeAccounts

The next step is to put these scripts and support for them in the ::CLI
module and after that we can check whether we can roll that into DeploymentHandler.

How does that sound?

Regards
          Racke

--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration.

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@...