Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create the schema at build time. #22

Merged
merged 21 commits into from Dec 27, 2012
Merged

Create the schema at build time. #22

merged 21 commits into from Dec 27, 2012

Conversation

schwern
Copy link
Collaborator

@schwern schwern commented Dec 27, 2012

Fair amount of refactoring going on here. Primarily to move responsibility for creating and managing the database into its own class, BackPAN::Index::Database. Then the db can be created at build time so the schema can see it.

For #21

Working on changing our schema loading to be in files we can debug rather
than in memory at runtime.  Going to take a bunch of work to do it right.
Meanwhile, quiet the test.
I want to switch to using Schema::Loader as its meant to be used, creating static
files at module install time rather than at runtime.  This is a first step to
isolating the schema creation process.
Easier to call it during the build process that way.
More functionality, no additional deps.

The version of Mouse is the one which comes with Debian stable.  Seems a
sane minimum.
This simplifies the "should update database" logic.

In the process tidied up our use of accessor types, making sure the
class types we use are always pre-declared to avoid Moose thinking
they're not class types.

Also eliminated the unncessary BUILD method in PBP.  Its now an
attribute default.
Separation of concerns and it lets other classes log.
Neatly moves a lot of code out of BackPAN::Index.
A small role, but it was getting repeated.

Questionable if BackPAN::Index should use it, given how much it overrides,
but the important thing about the role is it has an App::Cache object,
not the details of how its created.
Not much point in table creation having its own class any more.
This leaves just BackPAN::Index->_populate_database as the only
serious database access outside BackPAN::Index::Database.  Going
to leave that for now as I'm not sure where the index reading
and population should go.  Also that method is most of the
startup cost, its been tuned, and I don't want to mess with it
just now lest I get sidetracked optimizing.
Its no longer needed.  We're about to add some Module::Build specific code
to build the schema and the Makefile.PL will only confuse things.
Took a bit of doing.  DBIC::Schema::Loader will only make a schema using load_classes()
or load_namespaces() which spider all of lib/BackPAN/Index/, see non result classes and
freak out.  So we let it make a Schema class and throw it out.

We need to generate the database at build time so Schema::Loader can see it.
We can use the app cache's location just fine.
This isn't generated by Schema::Loader.
schwern added a commit that referenced this pull request Dec 27, 2012
@schwern schwern merged commit 2bc378d into master Dec 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant