Skip to content

Commit dcd50a7

Browse files
committed
DB Support PendingBlog Tags
1 parent 5068a4f commit dcd50a7

File tree

4 files changed

+180
-4
lines changed

4 files changed

+180
-4
lines changed

DB/etc/schema.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ CREATE TABLE blog_tag_map (
111111
created_at timestamptz not null default current_timestamp
112112
);
113113

114+
-- Map between tags <-> blogs so we can get a listing of tags for a blog, or a listing
115+
-- of blogs for a tag.
116+
CREATE TABLE pending_blog_tag_map (
117+
id serial PRIMARY KEY,
118+
blog_id int not null references pending_blog(id),
119+
tag_id int not null references tag(id),
120+
created_at timestamptz not null default current_timestamp
121+
);
122+
114123
-- When a user adds a tag, it's added to the pending table, and can be voted on,
115124
-- approved, or deleted.
116125
CREATE TABLE pending_tag (

DB/lib/BlogDB/DB/Result/PendingBlog.pm

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,21 @@ __PACKAGE__->add_unique_constraint("pending_blog_url_key", ["url"]);
183183

184184
=head1 RELATIONS
185185
186+
=head2 pending_blog_tag_maps
187+
188+
Type: has_many
189+
190+
Related object: L<BlogDB::DB::Result::PendingBlogTagMap>
191+
192+
=cut
193+
194+
__PACKAGE__->has_many(
195+
"pending_blog_tag_maps",
196+
"BlogDB::DB::Result::PendingBlogTagMap",
197+
{ "foreign.blog_id" => "self.id" },
198+
{ cascade_copy => 0, cascade_delete => 0 },
199+
);
200+
186201
=head2 submitter
187202
188203
Type: belongs_to
@@ -204,8 +219,8 @@ __PACKAGE__->belongs_to(
204219
);
205220

206221

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

210225

211226
# You can replace this text with custom code or comments, and it will be preserved on regeneration
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
use utf8;
2+
package BlogDB::DB::Result::PendingBlogTagMap;
3+
4+
# Created by DBIx::Class::Schema::Loader
5+
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6+
7+
=head1 NAME
8+
9+
BlogDB::DB::Result::PendingBlogTagMap
10+
11+
=cut
12+
13+
use strict;
14+
use warnings;
15+
16+
use base 'DBIx::Class::Core';
17+
18+
=head1 COMPONENTS LOADED
19+
20+
=over 4
21+
22+
=item * L<DBIx::Class::InflateColumn::DateTime>
23+
24+
=item * L<DBIx::Class::InflateColumn::Serializer>
25+
26+
=back
27+
28+
=cut
29+
30+
__PACKAGE__->load_components("InflateColumn::DateTime", "InflateColumn::Serializer");
31+
32+
=head1 TABLE: C<pending_blog_tag_map>
33+
34+
=cut
35+
36+
__PACKAGE__->table("pending_blog_tag_map");
37+
38+
=head1 ACCESSORS
39+
40+
=head2 id
41+
42+
data_type: 'integer'
43+
is_auto_increment: 1
44+
is_nullable: 0
45+
sequence: 'pending_blog_tag_map_id_seq'
46+
47+
=head2 blog_id
48+
49+
data_type: 'integer'
50+
is_foreign_key: 1
51+
is_nullable: 0
52+
53+
=head2 tag_id
54+
55+
data_type: 'integer'
56+
is_foreign_key: 1
57+
is_nullable: 0
58+
59+
=head2 created_at
60+
61+
data_type: 'timestamp with time zone'
62+
default_value: current_timestamp
63+
is_nullable: 0
64+
65+
=cut
66+
67+
__PACKAGE__->add_columns(
68+
"id",
69+
{
70+
data_type => "integer",
71+
is_auto_increment => 1,
72+
is_nullable => 0,
73+
sequence => "pending_blog_tag_map_id_seq",
74+
},
75+
"blog_id",
76+
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
77+
"tag_id",
78+
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
79+
"created_at",
80+
{
81+
data_type => "timestamp with time zone",
82+
default_value => \"current_timestamp",
83+
is_nullable => 0,
84+
},
85+
);
86+
87+
=head1 PRIMARY KEY
88+
89+
=over 4
90+
91+
=item * L</id>
92+
93+
=back
94+
95+
=cut
96+
97+
__PACKAGE__->set_primary_key("id");
98+
99+
=head1 RELATIONS
100+
101+
=head2 blog
102+
103+
Type: belongs_to
104+
105+
Related object: L<BlogDB::DB::Result::PendingBlog>
106+
107+
=cut
108+
109+
__PACKAGE__->belongs_to(
110+
"blog",
111+
"BlogDB::DB::Result::PendingBlog",
112+
{ id => "blog_id" },
113+
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
114+
);
115+
116+
=head2 tag
117+
118+
Type: belongs_to
119+
120+
Related object: L<BlogDB::DB::Result::Tag>
121+
122+
=cut
123+
124+
__PACKAGE__->belongs_to(
125+
"tag",
126+
"BlogDB::DB::Result::Tag",
127+
{ id => "tag_id" },
128+
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
129+
);
130+
131+
132+
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-21 05:50:00
133+
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+UAP0nhOyxxBAhXrW6c/xg
134+
135+
136+
# You can replace this text with custom code or comments, and it will be preserved on regeneration
137+
1;

DB/lib/BlogDB/DB/Result/Tag.pm

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,24 @@ __PACKAGE__->has_many(
126126
{ cascade_copy => 0, cascade_delete => 0 },
127127
);
128128

129+
=head2 pending_blog_tag_maps
129130
130-
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-10-06 18:19:48
131-
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3O/hbaaWPo4XH2M1y3Ogkw
131+
Type: has_many
132+
133+
Related object: L<BlogDB::DB::Result::PendingBlogTagMap>
134+
135+
=cut
136+
137+
__PACKAGE__->has_many(
138+
"pending_blog_tag_maps",
139+
"BlogDB::DB::Result::PendingBlogTagMap",
140+
{ "foreign.tag_id" => "self.id" },
141+
{ cascade_copy => 0, cascade_delete => 0 },
142+
);
143+
144+
145+
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-21 05:50:00
146+
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3Y3M0cdE/p2E54iYWV0nJQ
132147

133148

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

0 commit comments

Comments
 (0)