-- +goose Up
-- +goose StatementBegin
-- create medias table
CREATE TABLE medias (
    id SERIAL8 PRIMARY KEY,
    created_at timestamp NOT NULL default now(),
    updated_at timestamp NOT NULL default now(),

    tenant_id INT8 NOT NULL,
    user_id INT8 NOT NULL,
    post_id INT8 NOT NULL,
    storage_id INT8 NOT NULL,
    hash VARCHAR(32) NOT NULL,
    name VARCHAR(255) NOT NULL default '',
    mime_type VARCHAR(128) NOT NULL default '',
    size INT8 NOT NULL default 0,
    path VARCHAR(255) NOT NULL default ''
);

CREATE INDEX medias_tenant_id_index ON medias (tenant_id);
CREATE INDEX medias_user_id_index ON medias (user_id);
CREATE INDEX medias_post_id_index ON medias (post_id);
CREATE INDEX medias_storage_id_index ON medias (storage_id);
-- +goose StatementEnd

-- +goose Down
-- +goose StatementBegin
DROP TABLE medias;
-- +goose StatementEnd
