php-file-layer/files.sql

30 lines
1.2 KiB
SQL

-- Файлы
create table if not exists files (
id serial not null primary key,
added bigint not null,
user_id int,
sha1 varchar(40) not null,
format varchar(40) not null,
mimetype varchar(1024) not null,
size bigint not null,
width int not null default 0,
height int not null default 0,
props jsonb not null default '{}'::jsonb,
foreign key (user_id) references users (id) on delete set null on update cascade
);
create unique index on files (sha1);
create index on files (format);
create index on files (user_id);
comment on table files is 'Файлы';
comment on column files.added is 'UNIX время загрузки';
comment on column files.user_id is 'ID пользователя-владельца';
comment on column files.sha1 is 'SHA1 хеш';
comment on column files.format is 'Формат (расширение)';
comment on column files.mimetype is 'MIME-тип (реальный формат)';
comment on column files.size is 'Размер файла';
comment on column files.width is 'Ширина';
comment on column files.height is 'Высота';
comment on column files.propdata is 'Дополнительные свойства (EXIF, параметры видео)';