2021-12-04 02:26:25 -05:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
package GuestbookNg::Model::Test;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
2021-12-04 18:36:10 -05:00
|
|
|
use Mojo::Base -base, -signatures;
|
2021-12-04 02:26:25 -05:00
|
|
|
|
2021-12-04 18:36:10 -05:00
|
|
|
has 'pg';
|
|
|
|
|
|
|
|
sub new($class, $pg, $object) {
|
|
|
|
bless {
|
|
|
|
$pg => $object
|
|
|
|
}
|
2021-12-04 02:26:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
sub test_model($self, $string) {
|
|
|
|
"you've supplied: $string"
|
|
|
|
}
|
|
|
|
|
2021-12-04 18:36:10 -05:00
|
|
|
sub create_table($self) {
|
|
|
|
$self->pg->migrations->from_string(
|
|
|
|
"-- 1 up
|
|
|
|
CREATE TABLE IF NOT EXISTS messages (
|
|
|
|
id int,
|
|
|
|
date timestamp with time zone,
|
|
|
|
name varchar(255),
|
|
|
|
msg varchar(255)
|
|
|
|
);
|
|
|
|
-- 1 down
|
|
|
|
DROP TABLE messages;"
|
|
|
|
)->migrate();
|
|
|
|
}
|
|
|
|
|
|
|
|
sub now($self) {
|
|
|
|
$self->pg->db->query('SELECT NOW() AS now')->text()
|
|
|
|
}
|
|
|
|
|
2021-12-04 02:26:25 -05:00
|
|
|
1;
|