sqlite> delete from Auths where authName = "myAuth";
Error: foreign key constraint failed
helper sqlite => sub {my $sql = Mojo::SQLite->new('sqlite:mynewdb2.db')};
app->sqlite->on(connection => sub { my ($sql, $dbh) = @_; $dbh->do('PRAGMA foreign_keys = ON');});
app->sqlite->auto_migrate(1)->migrations->name('ConfigMgt')->from_string(<<EOF-- 1 upPRAGMA foreign_keys = ON;
create table if not exists Devices ( hostname text , ipaddress text , groupName text , authName text , connectionName text , promptName text , ignoreStatus int default 0, dateAdd datetime , dateMod datetime , primary key (hostname, ipaddress), constraint deviceAuth foreign key (authName)references Auths(authName) on delete restrict on update no action , constraint deviceScript foreign key (groupName)references Scripts(scriptName) on delete restrict on update no action , constraint devicePrompt foreign key (promptName)references Prompts(promptName) on delete restrict on update no action , constraint deviceConnection foreign key (connectionName)references Connections(connectionName) on delete restrict on update no action );--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/f8d536f2-4ea7-4447-9b8e-04cc639bb287%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to mojol...@googlegroups.com.
Alternatively you can use 'state $sqlite = ' inside the helper but this approach breaks the ability to run multiple separate apps in the same process, because it will make one $sqlite per whole process.-Dan
--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojolicious...@googlegroups.com.
To post to this group, send email to mojol...@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/CAO-W_8CVM9NnBMXuyvHi_FCT7p8%2B11FxTn6it9%3D%3D2JpUr78nfw%40mail.gmail.com.
To clarify Dan's answer about state variables (mostly, for myself).
If you run separate apps in the same process like these.
my $app1 = Test::Mojo->new('MyApp')->app;
my $app2 = Test::Mojo->new('MyApp')->app;
# now $app1->sqlite and $app2->sqlite is the same state
variable.
You got two apps in the same process and they share the same
state variable.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/CABMkAVUWJc-rYw4DhThw9YGcp7OdCh3d0djXRoPLpRkq-vESZg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mojolicious/e9a40bd8-f099-b2b1-d578-41a22e2b7371%40gmail.com.