Change the schema

This commit is contained in:
swagg boi 2022-02-09 21:02:35 -05:00
parent b95a1965bd
commit 7c89420bbd
2 changed files with 5 additions and 6 deletions

View file

@ -15,17 +15,17 @@ sub new($class, $pg, $pg_object) {
sub get_visitor_count($self) {
$self->pg->db->query(<<~'END_SQL')->text()
SELECT visitor_counter
SELECT counter_value
FROM counters
WHERE counter_id = 1;
WHERE counter_name = 'visitor';
END_SQL
}
sub increment_visitor_count($self) {
$self->pg->db->query(<<~'END_SQL')->text()
UPDATE counters
SET visitor_counter = visitor_counter + 1
WHERE counter_id = 1;
SET counter_value = counter_value + 1
WHERE counter_name = 'visitor';
END_SQL
}

View file

@ -1,8 +1,7 @@
CREATE TABLE IF NOT EXISTS counters (
counter_id SERIAL PRIMARY KEY,
counter_name VARCHAR(64),
counter_value INTEGER,
counter_date TIMESTAMPTZ SET DEFAULT NOW()
counter_value INTEGER
);
INSERT INTO counters (counter_name, counter_value)