caseycole589 has asked for the wisdom of the Perl Monks concerning the following question:

I am currently working through this <a http://oliverguenther.de/2014/04/applications-with-mojolicious-part-four-database-schemas-with-dbixclass/ tutorial on building a mojolicious web app for a project in the tutorial he talks about using this in a script to create a database schema. my $schema = Moblo::Schema->connect('dbi:SQLite:moblo.db'); $schema->deploy(); and I have tried running perl -e '...' putting it in different files and everything else I can think of, but to no success here is my code on https://www.github.com/caseycole589/MojoDojo => github I am pretty lost on how to get this thing to create the schema so any help would be appreciated.

I Apologize in advance for not being able to get links to format right. Sorry about spelling in title fixed.

Replies are listed 'Best First'.
Re: Help wiht mojolicious
by trippledubs (Deacon) on Mar 17, 2015 at 05:43 UTC
    Schema.pm goes in Moblo according to tutorial not Moblo/Schema. Put this code in MojoDojo/lib/t.pl
    use lib '.'; use Moblo::Schema; my $schema = Moblo::Schema->connect('dbi:SQLite:moblo.db'); $schema->deploy();
    Then run using 'perl t.pl'. If you get an error message about dependencies, install SQL::Translator. I found that in the DBIx::Class::Optional::Dependencies documentation. search on 'deploy' and it's about halfway down. You end up with a database file moblo.db that looks like this:
    sqlite> .schema CREATE TABLE posts ( id INTEGER PRIMARY KEY NOT NULL, author text NOT NULL, title text NOT NULL, content text NOT NULL, date_published datetime NOT NULL );
        Ahh I'm just starting to use GIT, this post seemed perfect excuse to practice. When I cloned I could have sworn it was not in the same directory as the tutorial indicated. I believe you, another git exercise will be showing rev. history I guess. The first error message I saw was "Can't locate in @INC", so I speculated that maybe OP was running it from the wrong directory.
      Hmm, I tried it all in one file, files are created, but they're mostly empty , no tables no schema gets created ... weird :)

        Guess: the AM author of the immediate parent node (to whom this reply is directed) is actually caseycole589 after logging out.

        If so, caseycole589, the same question as posed by the AM of the initial reply stands: what happened? What error/warning messages/ What output? If any, how did it differ from your intent?


        Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
        1. code
        2. verbatim error and/or warning messages
        3. a coherent explanation of what "doesn't work actually means.
Re: Help wiht mojolicious
by Anonymous Monk on Mar 17, 2015 at 04:40 UTC
    if there is no success, what happened?