Rename table

This commit is contained in:
swagg boi 2021-12-30 21:39:16 -05:00
parent 9f6144704b
commit d7613d8b04
4 changed files with 7 additions and 5 deletions

View file

@ -77,7 +77,7 @@ app->secrets(app->config->{'secrets'}) || die $@;
app->message->max_posts(app->config->{'max_posts'})
if app->config->{'max_posts'};
app->pg->migrations->from_dir('migrations')->migrate(3);
app->pg->migrations->from_dir('migrations')->migrate(4);
app->asset->store->paths(['assets']);
app->asset->process('swagg.css', 'css/swagg.css');

View file

@ -22,7 +22,7 @@ sub get_posts($self, $this_page = undef) {
SELECT to_char(message_date, 'Dy Mon DD HH:MI:SS AM TZ YYYY'),
visitor_name,
message
FROM messages
FROM guestbook
ORDER BY message_date DESC
LIMIT ? OFFSET ?;
END_SQL
@ -32,7 +32,7 @@ sub get_posts($self, $this_page = undef) {
SELECT to_char(message_date, 'Dy Mon DD HH:MI:SS AM TZ YYYY'),
visitor_name,
message
FROM messages
FROM guestbook
ORDER BY message_date DESC;
END_SQL
}
@ -40,7 +40,7 @@ sub get_posts($self, $this_page = undef) {
sub create_post($self, $name, $message) {
$self->pg->db->query(<<~'END_SQL', $name, $message)
INSERT INTO messages (message_date, visitor_name, message)
INSERT INTO guestbook (message_date, visitor_name, message)
VALUES (NOW(), ?, ?);
END_SQL
}
@ -58,7 +58,7 @@ sub get_last_page($self) {
}
sub get_post_count($self) {
$self->pg->db->query('SELECT count(*) FROM messages;')->text()
$self->pg->db->query('SELECT count(*) FROM guestbook;')->text()
}
1;

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

@ -0,0 +1 @@
ALTER TABLE guestbook RENAME TO messages;

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

@ -0,0 +1 @@
ALTER TABLE messages RENAME TO guestbook;