[Dbix-class] Dumping fixtures and loading in test script

Rob Kinyon rob.kinyon at gmail.com
Mon Nov 11 19:29:01 GMT 2013


On Mon, Nov 11, 2013 at 2:22 PM, Adam Witney <awitney at sgul.ac.uk> wrote:
>
>
>> On 11 Nov 2013, at 16:05, Rob Kinyon <rob.kinyon at gmail.com> wrote:
>>
>>> On Mon, Nov 11, 2013 at 10:48 AM, Adam Witney <awitney at sgul.ac.uk> wrote:
>>>
>>> Thanks again for your email Rob,
>>>
>>> Just to clarify from looking at the docs again, I would have to edit all my
>>> Result classes to add sim information, right? Wouldn't this break every time
>>> I refreshed the schema from the database (./script/xxx_create.pl model DB
>>> ... etc)?
>>
>> This is correct, assuming you're refreshing your schema from your
>> database. I would **STRONGLY** urge you to never do this. Your schema
>> files should be considered the source of truth, not your database.
>
> That's an interesting point of view. I tend to make my database changes directly with SQL and when I am ready regenerate the schema files from there.

This makes for poor testability. Otherwise, when you have a schema
change, you either:
1. Force everyone sharing the same developer instance to immediately
have to deal with your schema changes
2. Force everyone who isn't sharing the same developer instance to
have to deal with it when they do a "git pull"

Much better to have DBIx::Class::Schema::Versioned to just do the
right thing for you.

> One other question, when you used your $schema object, where do you put your connection information, to avoid having it in every single test script?

I generally have a test helper that creates a $schema object for me.
This helper would look in some configuration file that's specific for
tests and you can then control it from there. Configuration files are
amazing things.



More information about the DBIx-Class mailing list