2022-11-15 23:30:37 +01:00
|
|
|
package BurguillosInfo::DB::Migrations;
|
|
|
|
|
|
|
|
use v5.34.1;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
sub MIGRATIONS {
|
2023-05-07 18:10:55 +02:00
|
|
|
return (
|
|
|
|
'CREATE TABLE options (
|
|
|
|
name TEXT PRIMARY KEY,
|
|
|
|
value TEXT
|
|
|
|
)',
|
|
|
|
'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"',
|
|
|
|
'CREATE TABLE paths (
|
|
|
|
path TEXT PRIMARY KEY,
|
|
|
|
first_seen timestamp DEFAULT NOW()
|
|
|
|
)',
|
|
|
|
'CREATE TABLE requests (
|
|
|
|
uuid UUID DEFAULT uuid_generate_v4(),
|
|
|
|
remote_address TEXT NOT NULL,
|
|
|
|
user_agent TEXT NOT NULL,
|
|
|
|
params JSON NOT NULL,
|
|
|
|
date timestamp DEFAULT NOW(),
|
|
|
|
path TEXT,
|
|
|
|
FOREIGN KEY (path) REFERENCES paths(path)
|
|
|
|
)',
|
2023-05-02 20:52:39 +02:00
|
|
|
'ALTER TABLE paths ADD column last_seen TIMESTAMP;',
|
|
|
|
'ALTER TABLE paths ALTER COLUMN last_seen SET DEFAULT NOW();',
|
|
|
|
'ALTER TABLE requests ADD PRIMARY KEY (uuid)',
|
2023-05-02 21:59:31 +02:00
|
|
|
'CREATE INDEX request_extra_index on requests (date, path);',
|
2023-05-07 18:10:55 +02:00
|
|
|
'ALTER TABLE requests ADD column referer text;',
|
|
|
|
'CREATE INDEX request_referer_index on requests (referer);',
|
|
|
|
);
|
2022-11-15 23:30:37 +01:00
|
|
|
}
|
|
|
|
1;
|