Change the schema
This commit is contained in:
parent
b95a1965bd
commit
7c89420bbd
|
@ -15,17 +15,17 @@ sub new($class, $pg, $pg_object) {
|
||||||
|
|
||||||
sub get_visitor_count($self) {
|
sub get_visitor_count($self) {
|
||||||
$self->pg->db->query(<<~'END_SQL')->text()
|
$self->pg->db->query(<<~'END_SQL')->text()
|
||||||
SELECT visitor_counter
|
SELECT counter_value
|
||||||
FROM counters
|
FROM counters
|
||||||
WHERE counter_id = 1;
|
WHERE counter_name = 'visitor';
|
||||||
END_SQL
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
sub increment_visitor_count($self) {
|
sub increment_visitor_count($self) {
|
||||||
$self->pg->db->query(<<~'END_SQL')->text()
|
$self->pg->db->query(<<~'END_SQL')->text()
|
||||||
UPDATE counters
|
UPDATE counters
|
||||||
SET visitor_counter = visitor_counter + 1
|
SET counter_value = counter_value + 1
|
||||||
WHERE counter_id = 1;
|
WHERE counter_name = 'visitor';
|
||||||
END_SQL
|
END_SQL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
CREATE TABLE IF NOT EXISTS counters (
|
CREATE TABLE IF NOT EXISTS counters (
|
||||||
counter_id SERIAL PRIMARY KEY,
|
counter_id SERIAL PRIMARY KEY,
|
||||||
counter_name VARCHAR(64),
|
counter_name VARCHAR(64),
|
||||||
counter_value INTEGER,
|
counter_value INTEGER
|
||||||
counter_date TIMESTAMPTZ SET DEFAULT NOW()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO counters (counter_name, counter_value)
|
INSERT INTO counters (counter_name, counter_value)
|
||||||
|
|
Loading…
Reference in a new issue