Update the schema-reload script...

and found that DBIx produced multiple definitions for each of the two
result classes.  Edited them by hand to keep one each.
This commit is contained in:
barnold 2022-10-15 13:54:14 +01:00
parent 20a3cc4a04
commit d15be010ad
3 changed files with 18 additions and 513 deletions

View File

@ -17,7 +17,7 @@ else
-o dump_directory=./lib \
-o components='["InflateColumn::DateTime"]' \
-o debug=0 \
"Book::Schema" "dbi:Pg:"
"Book::Schema" "dbi:Pg:dbname=pg_book_catalog" pgc_owner
fi
exit 0

View File

@ -50,7 +50,7 @@ __PACKAGE__->table("author");
data_type: 'varchar'
is_nullable: 0
size: 64
size: 128
=cut
@ -64,7 +64,7 @@ __PACKAGE__->add_columns(
is_nullable => 0,
},
"name",
{ data_type => "varchar", is_nullable => 0, size => 64 },
{ data_type => "varchar", is_nullable => 0, size => 128 },
);
=head1 PRIMARY KEY
@ -111,8 +111,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-24 10:45:01
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:shJXsxbKrxkxGu7bwRS+rQ
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-10-13 19:14:12
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vwoWLTIl4qS7hd6gY1VPqw
# These lines were loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Author.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete
@ -121,249 +121,5 @@ __PACKAGE__->has_many(
# file again via Loader! See skip_load_external to disable
# this feature.
use utf8;
package Book::Schema::Result::Author;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Book::Schema::Result::Author
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut
__PACKAGE__->load_components("InflateColumn::DateTime");
=head1 TABLE: C<author>
=cut
__PACKAGE__->table("author");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 when_created
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=head2 name
data_type: 'varchar'
is_nullable: 0
size: 30
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"when_created",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
"name",
{ data_type => "varchar", is_nullable => 0, size => 30 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<author_name_unique>
=over 4
=item * L</name>
=back
=cut
__PACKAGE__->add_unique_constraint("author_name_unique", ["name"]);
=head1 RELATIONS
=head2 books
Type: has_many
Related object: L<Book::Schema::Result::Book>
=cut
__PACKAGE__->has_many(
"books",
"Book::Schema::Result::Book",
{ "foreign.author_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-18 10:43:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Qk0Z7HCPs/wL7PMWKSIk0w
1;
# End of lines loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Author.pm'
# These lines were loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Author.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete
# this section or remove that file from @INC, this section
# will be repeated redundantly when you re-create this
# file again via Loader! See skip_load_external to disable
# this feature.
use utf8;
package Book::Schema::Result::Author;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Book::Schema::Result::Author
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut
__PACKAGE__->load_components("InflateColumn::DateTime");
=head1 TABLE: C<author>
=cut
__PACKAGE__->table("author");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 when_created
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=head2 name
data_type: 'varchar'
is_nullable: 0
size: 30
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"when_created",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
"name",
{ data_type => "varchar", is_nullable => 0, size => 30 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<author_name_unique>
=over 4
=item * L</name>
=back
=cut
__PACKAGE__->add_unique_constraint("author_name_unique", ["name"]);
=head1 RELATIONS
=head2 books
Type: has_many
Related object: L<Book::Schema::Result::Book>
=cut
__PACKAGE__->has_many(
"books",
"Book::Schema::Result::Book",
{ "foreign.author_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-18 10:43:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Qk0Z7HCPs/wL7PMWKSIk0w
1;
# End of lines loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Author.pm'
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View File

@ -8,6 +8,15 @@ package Book::Schema::Result::Book;
Book::Schema::Result::Book
=head1 DESCRIPTION
A book present in the catalog of Project Gutenberg,
<https://www.gutenberg.org/>. Book titles are intentionally not unique,
not even within a given author (see for example "Paradise Lost" by John
Milton). In the catalog some titles have no author but for this table
the foreign key to author is required, so there is a bogus "[no author]"
row in the author table.
=cut
use strict;
@ -126,8 +135,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-24 10:45:01
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jn2J3I4s9utgM2u0qwDp3Q
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-10-13 19:14:12
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kNvd5HfYZCAV7yeq+lDGwA
# These lines were loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Book.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete
@ -136,265 +145,5 @@ __PACKAGE__->belongs_to(
# file again via Loader! See skip_load_external to disable
# this feature.
use utf8;
package Book::Schema::Result::Book;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Book::Schema::Result::Book
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut
__PACKAGE__->load_components("InflateColumn::DateTime");
=head1 TABLE: C<book>
=cut
__PACKAGE__->table("book");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 author_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 when_created
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=head2 title
data_type: 'varchar'
is_nullable: 0
size: 30
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"author_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"when_created",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
"title",
{ data_type => "varchar", is_nullable => 0, size => 30 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<book_title_unique>
=over 4
=item * L</title>
=back
=cut
__PACKAGE__->add_unique_constraint("book_title_unique", ["title"]);
=head1 RELATIONS
=head2 author
Type: belongs_to
Related object: L<Book::Schema::Result::Author>
=cut
__PACKAGE__->belongs_to(
"author",
"Book::Schema::Result::Author",
{ id => "author_id" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-18 10:43:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FYMjLIaXS+mX/Rlzefb8UQ
1;
# End of lines loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Book.pm'
# These lines were loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Book.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete
# this section or remove that file from @INC, this section
# will be repeated redundantly when you re-create this
# file again via Loader! See skip_load_external to disable
# this feature.
use utf8;
package Book::Schema::Result::Book;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Book::Schema::Result::Book
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut
__PACKAGE__->load_components("InflateColumn::DateTime");
=head1 TABLE: C<book>
=cut
__PACKAGE__->table("book");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 author_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 when_created
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=head2 title
data_type: 'varchar'
is_nullable: 0
size: 30
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"author_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"when_created",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
"title",
{ data_type => "varchar", is_nullable => 0, size => 30 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<book_title_unique>
=over 4
=item * L</title>
=back
=cut
__PACKAGE__->add_unique_constraint("book_title_unique", ["title"]);
=head1 RELATIONS
=head2 author
Type: belongs_to
Related object: L<Book::Schema::Result::Author>
=cut
__PACKAGE__->belongs_to(
"author",
"Book::Schema::Result::Author",
{ id => "author_id" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-18 10:43:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FYMjLIaXS+mX/Rlzefb8UQ
1;
# End of lines loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Book.pm'
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;