Skip to content

Commit f71eaf8

Browse files
author
Kaitlyn Parkhurst
committed
DB support for PendingBlog
1 parent c8551f1 commit f71eaf8

File tree

3 files changed

+256
-2
lines changed

3 files changed

+256
-2
lines changed

DB/etc/schema.sql

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,33 @@ CREATE TABLE blog (
5656
created_at timestamptz not null default current_timestamp
5757
);
5858

59+
-- Root table for the blog listing.
60+
CREATE TABLE pending_blog (
61+
id serial PRIMARY KEY,
62+
url text not null unique,
63+
img_url text ,
64+
rss_url text ,
65+
title text ,
66+
tagline text ,
67+
about text ,
68+
last_updated timestamptz ,
69+
is_published boolean not null default true,
70+
is_adult boolean not null default false,
71+
72+
-- If a registered user submitted the blog, they will be set as the
73+
-- submitter and can edit the blog data until it's approved.
74+
--
75+
-- If an anonymous user submitted the blog, they will have an edit
76+
-- token set in their cookies, and that token will be set here, they
77+
-- can edit the blog until their session expires.
78+
submitter_id int references person(id),
79+
edit_token text not null,
80+
81+
state text not null,
82+
83+
created_at timestamptz not null default current_timestamp
84+
);
85+
5986
-- RSS Reader will create these for the blogs.
6087
CREATE TABLE blog_entry (
6188
id serial PRIMARY KEY,
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
use utf8;
2+
package BlogDB::DB::Result::PendingBlog;
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::PendingBlog
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>
33+
34+
=cut
35+
36+
__PACKAGE__->table("pending_blog");
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_id_seq'
46+
47+
=head2 url
48+
49+
data_type: 'text'
50+
is_nullable: 0
51+
52+
=head2 img_url
53+
54+
data_type: 'text'
55+
is_nullable: 1
56+
57+
=head2 rss_url
58+
59+
data_type: 'text'
60+
is_nullable: 1
61+
62+
=head2 title
63+
64+
data_type: 'text'
65+
is_nullable: 1
66+
67+
=head2 tagline
68+
69+
data_type: 'text'
70+
is_nullable: 1
71+
72+
=head2 about
73+
74+
data_type: 'text'
75+
is_nullable: 1
76+
77+
=head2 last_updated
78+
79+
data_type: 'timestamp with time zone'
80+
is_nullable: 1
81+
82+
=head2 is_published
83+
84+
data_type: 'boolean'
85+
default_value: true
86+
is_nullable: 0
87+
88+
=head2 is_adult
89+
90+
data_type: 'boolean'
91+
default_value: false
92+
is_nullable: 0
93+
94+
=head2 submitter_id
95+
96+
data_type: 'integer'
97+
is_foreign_key: 1
98+
is_nullable: 1
99+
100+
=head2 edit_token
101+
102+
data_type: 'text'
103+
is_nullable: 0
104+
105+
=head2 state
106+
107+
data_type: 'text'
108+
is_nullable: 0
109+
110+
=head2 created_at
111+
112+
data_type: 'timestamp with time zone'
113+
default_value: current_timestamp
114+
is_nullable: 0
115+
116+
=cut
117+
118+
__PACKAGE__->add_columns(
119+
"id",
120+
{
121+
data_type => "integer",
122+
is_auto_increment => 1,
123+
is_nullable => 0,
124+
sequence => "pending_blog_id_seq",
125+
},
126+
"url",
127+
{ data_type => "text", is_nullable => 0 },
128+
"img_url",
129+
{ data_type => "text", is_nullable => 1 },
130+
"rss_url",
131+
{ data_type => "text", is_nullable => 1 },
132+
"title",
133+
{ data_type => "text", is_nullable => 1 },
134+
"tagline",
135+
{ data_type => "text", is_nullable => 1 },
136+
"about",
137+
{ data_type => "text", is_nullable => 1 },
138+
"last_updated",
139+
{ data_type => "timestamp with time zone", is_nullable => 1 },
140+
"is_published",
141+
{ data_type => "boolean", default_value => \"true", is_nullable => 0 },
142+
"is_adult",
143+
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
144+
"submitter_id",
145+
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
146+
"edit_token",
147+
{ data_type => "text", is_nullable => 0 },
148+
"state",
149+
{ data_type => "text", is_nullable => 0 },
150+
"created_at",
151+
{
152+
data_type => "timestamp with time zone",
153+
default_value => \"current_timestamp",
154+
is_nullable => 0,
155+
},
156+
);
157+
158+
=head1 PRIMARY KEY
159+
160+
=over 4
161+
162+
=item * L</id>
163+
164+
=back
165+
166+
=cut
167+
168+
__PACKAGE__->set_primary_key("id");
169+
170+
=head1 UNIQUE CONSTRAINTS
171+
172+
=head2 C<pending_blog_url_key>
173+
174+
=over 4
175+
176+
=item * L</url>
177+
178+
=back
179+
180+
=cut
181+
182+
__PACKAGE__->add_unique_constraint("pending_blog_url_key", ["url"]);
183+
184+
=head1 RELATIONS
185+
186+
=head2 submitter
187+
188+
Type: belongs_to
189+
190+
Related object: L<BlogDB::DB::Result::Person>
191+
192+
=cut
193+
194+
__PACKAGE__->belongs_to(
195+
"submitter",
196+
"BlogDB::DB::Result::Person",
197+
{ id => "submitter_id" },
198+
{
199+
is_deferrable => 0,
200+
join_type => "LEFT",
201+
on_delete => "NO ACTION",
202+
on_update => "NO ACTION",
203+
},
204+
);
205+
206+
207+
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-05 14:49:36
208+
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4Ms5W+IBBcccbKjRTi1z8A
209+
210+
211+
# You can replace this text with custom code or comments, and it will be preserved on regeneration
212+
1;

DB/lib/BlogDB/DB/Result/Person.pm

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,21 @@ __PACKAGE__->has_many(
189189
{ cascade_copy => 0, cascade_delete => 0 },
190190
);
191191

192+
=head2 pending_blogs
193+
194+
Type: has_many
195+
196+
Related object: L<BlogDB::DB::Result::PendingBlog>
197+
198+
=cut
199+
200+
__PACKAGE__->has_many(
201+
"pending_blogs",
202+
"BlogDB::DB::Result::PendingBlog",
203+
{ "foreign.submitter_id" => "self.id" },
204+
{ cascade_copy => 0, cascade_delete => 0 },
205+
);
206+
192207
=head2 person_follow_blog_maps
193208
194209
Type: has_many
@@ -265,8 +280,8 @@ __PACKAGE__->has_many(
265280
);
266281

267282

268-
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-10-06 18:19:48
269-
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pH+QD6dGCkPfgVuSzSHdGg
283+
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2021-11-04 01:11:09
284+
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uamr/+RThTQZLjXkv6wcxQ
270285

271286
sub setting {
272287
my ( $self, $setting, $value ) = @_;

0 commit comments

Comments
 (0)