[DB][MEDIA] Small database structure changes
This commit is contained in:
parent
4507b12976
commit
f2ab77c3a9
|
@ -43,14 +43,14 @@ class File extends Entity
|
||||||
|
|
||||||
private int $id;
|
private int $id;
|
||||||
private ?string $url;
|
private ?string $url;
|
||||||
private ?bool $is_url_protected;
|
|
||||||
private ?string $url_hash;
|
private ?string $url_hash;
|
||||||
private ?string $file_hash;
|
private ?string $file_hash;
|
||||||
private ?int $actor_id;
|
private ?int $actor_id;
|
||||||
private ?string $mimetype;
|
private ?string $mimetype;
|
||||||
private ?int $size;
|
|
||||||
private ?string $title;
|
private ?string $title;
|
||||||
private ?bool $is_local;
|
private ?bool $is_local;
|
||||||
|
private ?bool $is_nsfw;
|
||||||
|
private ?bool $is_url_protected;
|
||||||
private DateTimeInterface $modified;
|
private DateTimeInterface $modified;
|
||||||
|
|
||||||
public function setId(int $id): self
|
public function setId(int $id): self
|
||||||
|
@ -75,17 +75,6 @@ class File extends Entity
|
||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setIsUrlProtected(?bool $is_url_protected): self
|
|
||||||
{
|
|
||||||
$this->is_url_protected = $is_url_protected;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIsUrlProtected(): ?bool
|
|
||||||
{
|
|
||||||
return $this->is_url_protected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUrlHash(?string $url_hash): self
|
public function setUrlHash(?string $url_hash): self
|
||||||
{
|
{
|
||||||
$this->url_hash = $url_hash;
|
$this->url_hash = $url_hash;
|
||||||
|
@ -130,17 +119,6 @@ class File extends Entity
|
||||||
return $this->mimetype;
|
return $this->mimetype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setSize(?int $size): self
|
|
||||||
{
|
|
||||||
$this->size = $size;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSize(): ?int
|
|
||||||
{
|
|
||||||
return $this->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setTitle(?string $title): self
|
public function setTitle(?string $title): self
|
||||||
{
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
|
@ -163,6 +141,28 @@ class File extends Entity
|
||||||
return $this->is_local;
|
return $this->is_local;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setIsNsfw(?bool $is_nsfw): self
|
||||||
|
{
|
||||||
|
$this->is_nsfw = $is_nsfw;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsNsfw(): ?bool
|
||||||
|
{
|
||||||
|
return $this->is_nsfw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIsUrlProtected(?bool $is_url_protected): self
|
||||||
|
{
|
||||||
|
$this->is_url_protected = $is_url_protected;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIsUrlProtected(): ?bool
|
||||||
|
{
|
||||||
|
return $this->is_url_protected;
|
||||||
|
}
|
||||||
|
|
||||||
public function setModified(DateTimeInterface $modified): self
|
public function setModified(DateTimeInterface $modified): self
|
||||||
{
|
{
|
||||||
$this->modified = $modified;
|
$this->modified = $modified;
|
||||||
|
@ -226,14 +226,14 @@ class File extends Entity
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'id' => ['type' => 'serial', 'not null' => true],
|
'id' => ['type' => 'serial', 'not null' => true],
|
||||||
'url' => ['type' => 'text', 'description' => 'URL after following possible redirections'],
|
'url' => ['type' => 'text', 'description' => 'URL after following possible redirections'],
|
||||||
'is_url_protected' => ['type' => 'bool', 'default' => false, 'description' => 'true when URL is private (needs login)'],
|
|
||||||
'url_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of destination URL (url field)'],
|
'url_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of destination URL (url field)'],
|
||||||
'file_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of the file contents, if the file is stored locally'],
|
'file_hash' => ['type' => 'varchar', 'length' => 64, 'description' => 'sha256 of the file contents, if the file is stored locally'],
|
||||||
'actor_id' => ['type' => 'int', 'description' => 'If set, used so each actor can have a version of this file (for avatars, for instance)'],
|
'actor_id' => ['type' => 'int', 'description' => 'If set, used so each actor can have a version of this file (for avatars, for instance)'],
|
||||||
'mimetype' => ['type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'],
|
'mimetype' => ['type' => 'varchar', 'length' => 50, 'description' => 'mime type of resource'],
|
||||||
'size' => ['type' => 'int', 'description' => 'size of resource when available'],
|
|
||||||
'title' => ['type' => 'text', 'description' => 'title of resource when available'],
|
'title' => ['type' => 'text', 'description' => 'title of resource when available'],
|
||||||
'is_local' => ['type' => 'bool', 'description' => 'whether the file is stored locally'],
|
'is_local' => ['type' => 'bool', 'description' => 'whether the file is stored locally'],
|
||||||
|
'is_nsfw' => ['type' => 'bool', 'default' => false, 'description' => 'whether the file is NSFW'],
|
||||||
|
'is_url_protected' => ['type' => 'bool', 'default' => false, 'description' => 'true when URL is private (needs login)'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['id'],
|
'primary key' => ['id'],
|
||||||
|
|
|
@ -41,7 +41,7 @@ class FileToNote extends Entity
|
||||||
// {{{ Autocode
|
// {{{ Autocode
|
||||||
|
|
||||||
private int $file_id;
|
private int $file_id;
|
||||||
private int $activity_id;
|
private int $note_id;
|
||||||
private DateTimeInterface $modified;
|
private DateTimeInterface $modified;
|
||||||
|
|
||||||
public function setFileId(int $file_id): self
|
public function setFileId(int $file_id): self
|
||||||
|
@ -55,15 +55,15 @@ class FileToNote extends Entity
|
||||||
return $this->file_id;
|
return $this->file_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setActivityId(int $activity_id): self
|
public function setNoteId(int $note_id): self
|
||||||
{
|
{
|
||||||
$this->activity_id = $activity_id;
|
$this->note_id = $note_id;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getActivityId(): int
|
public function getNoteId(): int
|
||||||
{
|
{
|
||||||
return $this->activity_id;
|
return $this->note_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setModified(DateTimeInterface $modified): self
|
public function setModified(DateTimeInterface $modified): self
|
||||||
|
@ -82,20 +82,20 @@ class FileToNote extends Entity
|
||||||
public static function schemaDef(): array
|
public static function schemaDef(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => 'file_to_activity',
|
'name' => 'file_to_note',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'file_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of file'],
|
'file_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of file'],
|
||||||
'activity_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of the activity it belongs to'],
|
'note_id' => ['type' => 'int', 'not null' => true, 'description' => 'id of the note it belongs to'],
|
||||||
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
'modified' => ['type' => 'timestamp', 'not null' => true, 'default' => 'CURRENT_TIMESTAMP', 'description' => 'date this record was modified'],
|
||||||
],
|
],
|
||||||
'primary key' => ['file_id', 'activity_id'],
|
'primary key' => ['file_id', 'note_id'],
|
||||||
'foreign keys' => [
|
'foreign keys' => [
|
||||||
'file_to_activity_file_id_fkey' => ['file', ['file_id' => 'id']],
|
'file_to_note_file_id_fkey' => ['file', ['file_id' => 'id']],
|
||||||
'file_to_activity_activity_id_fkey' => ['notice', ['activity_id' => 'id']],
|
'file_to_note_note_id_fkey' => ['note', ['note_id' => 'id']],
|
||||||
],
|
],
|
||||||
'indexes' => [
|
'indexes' => [
|
||||||
'file_id_idx' => ['file_id'],
|
'file_id_idx' => ['file_id'],
|
||||||
'activity_id_idx' => ['activity_id'],
|
'note_id_idx' => ['note_id'],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user