Standardize examples/docs on Schema::Loader schema naming
[dbsrgits/DBIx-Class.git] / examples / Schema / insertdb.pl
old mode 100644 (file)
new mode 100755 (executable)
index e8603bb..15bf71b
@@ -1,9 +1,11 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 
-use MyDatabase::Main;
 use strict;
+use warnings;
 
-my $schema = MyDatabase::Main->connect('dbi:SQLite:db/example.db');
+use MyApp::Schema;
+
+my $schema = MyApp::Schema->connect('dbi:SQLite:db/example.db');
 
 #  here's some of the sql that is going to be generated by the schema
 #  INSERT INTO artist VALUES (NULL,'Michael Jackson');
@@ -47,10 +49,10 @@ my %tracks = (
 
 my @tracks;
 foreach my $track (keys %tracks) {
-    my $cdname = $schema->resultset('Cd')->search({
+    my $cd = $schema->resultset('Cd')->find({
         title => $tracks{$track},
     });
-    push @tracks, [$cdname->first, $track];
+    push @tracks, [$cd->id, $track];
 }
 
 $schema->populate('Track',[