New migration for Replies

This commit is contained in:
swagg boi 2022-08-19 22:36:26 -04:00
parent aa56927306
commit a5599ce259
5 changed files with 18 additions and 3 deletions

View file

@ -91,10 +91,11 @@ any [qw{GET POST}], '/post', sub ($c) {
# Configure things
app->secrets(app->config->{'secrets'}) || die $@;
app->pg->migrations->from_dir('migrations')->migrate(3);
app->pg->migrations->from_dir('migrations')->migrate(4);
if (my $threads_per_page = app->config->{'threads_per_page'}) {
app->thread->threads_per_page($threads_per_page)
say $threads_per_page;
app->thread->threads_per_page($threads_per_page);
}
app->asset->process('main.css', 'css/PostText.css');

View file

@ -24,5 +24,7 @@ Run the tests locally (against development environment)
## TODOs
1. Default 'threads per page' is broken if config file isn't correct
(should pick up the default value wtf)
1. Pick a date format
1. Reply model

View file

@ -59,7 +59,7 @@ sub get_threads_by_page($self, $this_page = 1) {
}
sub threads_per_page($self, $value = undef) {
$self->{'threads_per_page'} = $value // $self->{'threads_per_page'}
$self->{'threads_per_page'} = $value // $self->{'threads_per_page'};
}
sub get_last_page($self) {

1
migrations/4/down.sql Normal file
View file

@ -0,0 +1 @@
DROP TABLE replies;

11
migrations/4/up.sql Normal file
View file

@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS replies (
reply_id SERIAL PRIMARY KEY,
thread_id INT,
reply_date TIMESTAMPTZ NOT NULL DEFAULT now(),
reply_author VARCHAR(64),
reply_body VARCHAR(4096),
hidden_status BOOLEAN NOT NULL,
flagged_status BOOLEAN NOT NULL,
FOREIGN KEY (thread_id)
REFERENCES threads(thread_id)
);