diff --git a/README.md b/README.md index 1fa049b..5ad508d 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ Run the tests locally (against development environment): [bcrypt](https://metacpan.org/pod/Mojolicious::Plugin::BcryptSecure) 1. Some sort of admin/moderator login and view 1. CSS +1. Use [_tally](https://www.sqlstyle.guide/#uniform-suffixes) suffix + instead of _counter or _count ## Crazy future ideas diff --git a/cpanfile b/cpanfile index 31dbd98..775be4c 100644 --- a/cpanfile +++ b/cpanfile @@ -2,3 +2,4 @@ requires 'Mojolicious'; requires 'Mojo::Pg'; requires 'Mojolicious::Plugin::TagHelpers::Pagination'; requires 'Mojolicious::Plugin::AssetPack'; +requires 'Mojolicious::Plugin::BcryptSecure'; diff --git a/lib/PostText.pm b/lib/PostText.pm index 8b68045..de80fe4 100644 --- a/lib/PostText.pm +++ b/lib/PostText.pm @@ -11,6 +11,7 @@ sub startup($self) { $self->plugin('Config'); $self->plugin('TagHelpers::Pagination'); $self->plugin(AssetPack => {pipes => [qw{Css Combine}]}); + $self->plugin('BcryptSecure'); # Helpers $self->helper(pg => sub ($c) { @@ -35,7 +36,7 @@ sub startup($self) { # Finish configuring some things $self->secrets($self->config->{'secrets'}) || die $@; - $self->pg->migrations->from_dir('migrations')->migrate(6); + $self->pg->migrations->from_dir('migrations')->migrate(7); if (my $threads_per_page = $self->config->{'threads_per_page'}) { $self->thread->per_page($threads_per_page) diff --git a/lib/PostText/Model/Thread.pm b/lib/PostText/Model/Thread.pm index 3679c6d..1bc8c47 100644 --- a/lib/PostText/Model/Thread.pm +++ b/lib/PostText/Model/Thread.pm @@ -42,8 +42,8 @@ sub by_page($self, $this_page = 1) { t.thread_body AS body, COUNT(r.*) AS remark_count, t.bump_count AS bump_count - FROM threads t - LEFT JOIN remarks r + FROM threads AS t + LEFT JOIN remarks AS r ON t.thread_id = r.thread_id WHERE NOT t.hidden_status GROUP BY t.thread_id diff --git a/migrations/7/down.sql b/migrations/7/down.sql new file mode 100644 index 0000000..2cd6077 --- /dev/null +++ b/migrations/7/down.sql @@ -0,0 +1 @@ +DROP TABLE moderators; diff --git a/migrations/7/up.sql b/migrations/7/up.sql new file mode 100644 index 0000000..e181439 --- /dev/null +++ b/migrations/7/up.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS moderators ( + moderator_id SERIAL PRIMARY KEY, + moderator_name VARCHAR(64) NOT NULL, + email_addr VARCHAR(320) NOT NULL, + password_hash VARCHAR(64) NOT NULL, + creation_date TIMESTAMPTZ NOT NULL DEFAULT NOW(), + last_login_date TIMESTAMPTZ NOT NULL DEFAULT '2000-01-01', + lock_status BOOLEAN NOT NULL DEFAULT FALSE +);