Files
image-storage/db/migrations/20260316172048_init_images.sql
2026-03-16 21:45:39 +03:00

28 lines
572 B
SQL

-- +goose Up
-- +goose StatementBegin
CREATE TABLE images (
id varchar primary key not null,
data blob not null,
user_id integer not null,
created_at datetime default current_timestamp,
updated_at datetime default current_timestamp,
FOREIGN KEY(user_id) REFERENCES users(id)
);
CREATE TRIGGER update_images_updated_at
AFTER UPDATE ON images
FOR EACH ROW
BEGIN
UPDATE images
SET updated_at = current_timestamp
WHERE id = OLD.id;
END;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE images;
-- +goose StatementEnd