Set default value for message_date column
This commit is contained in:
parent
baca0cd515
commit
da91154df7
|
@ -50,4 +50,3 @@ Add the `-v` option for more verbose output
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
||||||
1. Input validation
|
1. Input validation
|
||||||
1. Set date in the DB rather than the model
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ app->secrets(app->config->{'secrets'}) || die $@;
|
||||||
app->message->max_posts(app->config->{'max_posts'})
|
app->message->max_posts(app->config->{'max_posts'})
|
||||||
if app->config->{'max_posts'};
|
if app->config->{'max_posts'};
|
||||||
|
|
||||||
app->pg->migrations->from_dir('migrations')->migrate(5);
|
app->pg->migrations->from_dir('migrations')->migrate(6);
|
||||||
|
|
||||||
app->asset->store->paths(['assets']);
|
app->asset->store->paths(['assets']);
|
||||||
app->asset->process('swagg.css', 'css/swagg.css');
|
app->asset->process('swagg.css', 'css/swagg.css');
|
||||||
|
|
|
@ -46,20 +46,14 @@ sub get_posts($self, $this_page = undef) {
|
||||||
sub create_post($self, $name, $message, $url = undef, $spam = 1) {
|
sub create_post($self, $name, $message, $url = undef, $spam = 1) {
|
||||||
if ($url) {
|
if ($url) {
|
||||||
$self->pg->db->query(<<~'END_SQL', $name, $message, $url, $spam)
|
$self->pg->db->query(<<~'END_SQL', $name, $message, $url, $spam)
|
||||||
INSERT INTO messages (
|
INSERT INTO messages (visitor_name, message, homepage_url, is_spam)
|
||||||
message_date,
|
VALUES (?, ?, ?, ?);
|
||||||
visitor_name,
|
|
||||||
message,
|
|
||||||
homepage_url,
|
|
||||||
is_spam
|
|
||||||
)
|
|
||||||
VALUES (NOW(), ?, ?, ?, ?);
|
|
||||||
END_SQL
|
END_SQL
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$self->pg->db->query(<<~'END_SQL', $name, $message, $spam)
|
$self->pg->db->query(<<~'END_SQL', $name, $message, $spam)
|
||||||
INSERT INTO messages (message_date, visitor_name, message, is_spam)
|
INSERT INTO messages (visitor_name, message, is_spam)
|
||||||
VALUES (NOW(), ?, ?, ?);
|
VALUES (?, ?, ?);
|
||||||
END_SQL
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
migrations/6/down.sql
Normal file
3
migrations/6/down.sql
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
ALTER TABLE messages
|
||||||
|
ALTER COLUMN message_date
|
||||||
|
DROP DEFAULT;
|
3
migrations/6/up.sql
Normal file
3
migrations/6/up.sql
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
ALTER TABLE messages
|
||||||
|
ALTER COLUMN message_date
|
||||||
|
SET DEFAULT NOW();
|
Loading…
Reference in a new issue