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

Support for multiple schemas on same server? #137

Open
jbakerdev opened this issue Aug 17, 2020 · 0 comments
Open

Support for multiple schemas on same server? #137

jbakerdev opened this issue Aug 17, 2020 · 0 comments

Comments

@jbakerdev
Copy link

jbakerdev commented Aug 17, 2020

Hi folks - thanks for all your work on this package. I'm trying to integrate this with an existing app that piggy-backs off of a bugzilla server/database, but has additional app-specific database schemas. Not sure if I'm doing certain things incorrectly, but I'm beginning to wonder if the code wasn't intended for my use case.

My situation: Bugzilla server with fairly extensive customer-designed apps/addons

  • MySQL 5.5 server
    • Bugzilla schema for all standard bugzilla functionality (aka "bugzilla")
    • Additional schema 1 for in-house addon 1 (aka "addon1")
    • Additional schema 2 for in-house addon 1 (aka "addon2")
  • Using DBIx::Class, with result classes set up per the recommendations in DBIx::Class::Manual::FAQ:
If your database server allows you to run queries across multiple databases at once, then so can DBIx::Class. 
All you need to do is make sure you write the database name as part of the table call. Eg:

    __PACKAGE__->table('mydb.mytablename');

And load all the Result classes for both / all databases by calling "load_namespaces" in DBIx::Class::Schema.

And my classes are organized like this:

  • MyApp
    • Schema
      • Result
        • Bugzilla
          • Profile.pm
        • Addon1
          • Widget.pm
        • Addon2
          • Thingy.pm

Issues / Questions

  • When running "dbic-migration" commands against my develoipment server (not the sandbox, but also mysql) what should I use for the "database=" portion of the dsn?
    • I have been assuming that I have to pick a "main" schema (where the versions table would live)? Or is there a way to version schemas separately?
    • I have relations between the different schemas, and I've already found that the generated SQL doesn't always prefix the table name with the database name - I can live with making manual changes (or investigate with the SQLTranslator folks?), just want to know if i'm doing something wrong in preparing/installing and running migrations...
  • I think the above is the cause of my issues when dumping fixtures (using a single database in the --dsn flag)
    • I receive the error "DBIx::Class::Schema::source(): Can't find source for Addon1::Widget at (eval 260) line 17"
    • After some initial sleuthing, Schema::source() is looking for "Widget" instead of "Addon1::Widget"
    • Is this something I can solve with the right set of "extra_schema_loader_args"?

Thanks in advance!

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

No branches or pull requests

1 participant