33 lines
1 KiB
MySQL
33 lines
1 KiB
MySQL
|
-- +goose Up
|
||
|
-- +goose StatementBegin
|
||
|
CREATE TABLE devices (
|
||
|
slug VARCHAR(255) PRIMARY KEY COLLATE NOCASE,
|
||
|
disabled TINYINT NOT NULL DEFAULT 0,
|
||
|
name TEXT NOT NULL COLLATE NOCASE,
|
||
|
resolution_x DOUBLE NOT NULL,
|
||
|
resolution_y DOUBLE NOT NULL,
|
||
|
aspect_ratio_tolerance DOUBLE NOT NULL DEFAULT 0.2,
|
||
|
min_x INTEGER NOT NULL DEFAULT 0,
|
||
|
min_y INTEGER NOT NULL DEFAULT 0,
|
||
|
max_x INTEGER NOT NULL DEFAULT 0,
|
||
|
max_y INTEGER NOT NULL DEFAULT 0,
|
||
|
nsfw TINYINT NOT NULL DEFAULT 0,
|
||
|
single_folder_mode TINYINT NOT NULL DEFAULT 0,
|
||
|
created_at BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
|
||
|
updated_at BIGINT NOT NULL DEFAULT (strftime('%s', 'now'))
|
||
|
);
|
||
|
|
||
|
CREATE UNIQUE INDEX idx_devices_unique_slug ON devices(slug);
|
||
|
|
||
|
CREATE TRIGGER devices_update_timestamp AFTER UPDATE ON devices FOR EACH ROW
|
||
|
BEGIN
|
||
|
UPDATE devices SET updated_at = strftime('%s', 'now') WHERE slug = old.slug;
|
||
|
END;
|
||
|
|
||
|
-- +goose StatementEnd
|
||
|
|
||
|
-- +goose Down
|
||
|
-- +goose StatementBegin
|
||
|
DROP TABLE devices;
|
||
|
-- +goose StatementEnd
|