Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DB Support PendingBlog Tags
  • Loading branch information
symkat committed Nov 21, 2021
1 parent 5068a4f commit dcd50a7
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 4 deletions.
9 changes: 9 additions & 0 deletions DB/etc/schema.sql
Expand Up @@ -111,6 +111,15 @@ CREATE TABLE blog_tag_map (
created_at timestamptz not null default current_timestamp
);

-- Map between tags <-> blogs so we can get a listing of tags for a blog, or a listing
-- of blogs for a tag.
CREATE TABLE pending_blog_tag_map (
id serial PRIMARY KEY,
blog_id int not null references pending_blog(id),
tag_id int not null references tag(id),
created_at timestamptz not null default current_timestamp
);

-- When a user adds a tag, it's added to the pending table, and can be voted on,
-- approved, or deleted.
CREATE TABLE pending_tag (
Expand Down
19 changes: 17 additions & 2 deletions DB/lib/BlogDB/DB/Result/PendingBlog.pm
Expand Up @@ -183,6 +183,21 @@ __PACKAGE__->add_unique_constraint("pending_blog_url_key", ["url"]);

=head1 RELATIONS
=head2 pending_blog_tag_maps
Type: has_many
Related object: L<BlogDB::DB::Result::PendingBlogTagMap>
=cut

__PACKAGE__->has_many(
"pending_blog_tag_maps",
"BlogDB::DB::Result::PendingBlogTagMap",
{ "foreign.blog_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 submitter
Type: belongs_to
Expand All @@ -204,8 +219,8 @@ __PACKAGE__->belongs_to(
);


# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-20 18:43:08
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Nmw2JISUfm8bGD434BTYaw
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-21 05:50:00
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8bolOwz93fFR3o6V2hJ5rA


# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down
137 changes: 137 additions & 0 deletions DB/lib/BlogDB/DB/Result/PendingBlogTagMap.pm
@@ -0,0 +1,137 @@
use utf8;
package BlogDB::DB::Result::PendingBlogTagMap;

# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE

=head1 NAME
BlogDB::DB::Result::PendingBlogTagMap
=cut

use strict;
use warnings;

use base 'DBIx::Class::Core';

=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=item * L<DBIx::Class::InflateColumn::Serializer>
=back
=cut

__PACKAGE__->load_components("InflateColumn::DateTime", "InflateColumn::Serializer");

=head1 TABLE: C<pending_blog_tag_map>
=cut

__PACKAGE__->table("pending_blog_tag_map");

=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_auto_increment: 1
is_nullable: 0
sequence: 'pending_blog_tag_map_id_seq'
=head2 blog_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 tag_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 created_at
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=cut

__PACKAGE__->add_columns(
"id",
{
data_type => "integer",
is_auto_increment => 1,
is_nullable => 0,
sequence => "pending_blog_tag_map_id_seq",
},
"blog_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"tag_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"created_at",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
);

=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut

__PACKAGE__->set_primary_key("id");

=head1 RELATIONS
=head2 blog
Type: belongs_to
Related object: L<BlogDB::DB::Result::PendingBlog>
=cut

__PACKAGE__->belongs_to(
"blog",
"BlogDB::DB::Result::PendingBlog",
{ id => "blog_id" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);

=head2 tag
Type: belongs_to
Related object: L<BlogDB::DB::Result::Tag>
=cut

__PACKAGE__->belongs_to(
"tag",
"BlogDB::DB::Result::Tag",
{ id => "tag_id" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);


# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-21 05:50:00
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+UAP0nhOyxxBAhXrW6c/xg


# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
19 changes: 17 additions & 2 deletions DB/lib/BlogDB/DB/Result/Tag.pm
Expand Up @@ -126,9 +126,24 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);

=head2 pending_blog_tag_maps
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-10-06 18:19:48
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3O/hbaaWPo4XH2M1y3Ogkw
Type: has_many
Related object: L<BlogDB::DB::Result::PendingBlogTagMap>
=cut

__PACKAGE__->has_many(
"pending_blog_tag_maps",
"BlogDB::DB::Result::PendingBlogTagMap",
{ "foreign.tag_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);


# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-21 05:50:00
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3Y3M0cdE/p2E54iYWV0nJQ


# You can replace this text with custom code or comments, and it will be preserved on regeneration
Expand Down

0 comments on commit dcd50a7

Please sign in to comment.