Mojolicious Deploying database schema

余生长醉 提交于 2019-12-11 12:22:46

问题


I am currently working through this 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 with no success.

Here is my code on GitHub.

I am pretty lost on how to get this thing to create the schema so any help would be appreciated.


回答1:


It's not clear why the author wrote only a part of the deployment script. Perhaps he thought it was obvious that you needed use Moblo::Schema in there. Perhaps he was right.

This program works fine. Call it anything you like—say deploy.pl—and put it in the moblo/lib directory.

use strict;
use warnings;

use Moblo::Schema;

my $schema = Moblo::Schema->connect('dbi:SQLite:moblo.db');
$schema->deploy();


来源:https://stackoverflow.com/questions/29091017/mojolicious-deploying-database-schema

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!