From 74c782749fe975f3226ae4170d3fb32d9e44049a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sun, 2 Jun 2024 13:16:51 +0200 Subject: [PATCH] Add the SQL structure to the DDL PIP --- .../database/update_com.woltlab.wcf_6.1.php | 107 ++++++++++++++++++ .../file/temporary/FileTemporary.class.php | 2 +- wcfsetup/setup/db/install.sql | 4 +- 3 files changed, 110 insertions(+), 3 deletions(-) diff --git a/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_6.1.php b/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_6.1.php index 26e50c3d5f..988e920e3a 100644 --- a/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_6.1.php +++ b/wcfsetup/install/files/acp/database/update_com.woltlab.wcf_6.1.php @@ -8,13 +8,21 @@ * @license GNU Lesser General Public License */ +use wcf\system\database\table\column\BigintDatabaseTableColumn; +use wcf\system\database\table\column\CharDatabaseTableColumn; use wcf\system\database\table\column\DefaultFalseBooleanDatabaseTableColumn; +use wcf\system\database\table\column\IntDatabaseTableColumn; use wcf\system\database\table\column\NotNullInt10DatabaseTableColumn; use wcf\system\database\table\column\NotNullVarchar191DatabaseTableColumn; +use wcf\system\database\table\column\NotNullVarchar255DatabaseTableColumn; +use wcf\system\database\table\column\ObjectIdDatabaseTableColumn; +use wcf\system\database\table\column\TextDatabaseTableColumn; +use wcf\system\database\table\column\VarbinaryDatabaseTableColumn; use wcf\system\database\table\column\VarcharDatabaseTableColumn; use wcf\system\database\table\DatabaseTable; use wcf\system\database\table\index\DatabaseTableForeignKey; use wcf\system\database\table\index\DatabaseTableIndex; +use wcf\system\database\table\index\DatabaseTablePrimaryIndex; use wcf\system\database\table\PartialDatabaseTable; return [ @@ -52,5 +60,104 @@ return [ ->indices([ DatabaseTableIndex::create('identifier') ->columns(['identifier']), + ]), + DatabaseTable::create('wcf1_file') + ->columns([ + ObjectIdDatabaseTableColumn::create('fileID'), + NotNullVarchar255DatabaseTableColumn::create('filename'), + BigintDatabaseTableColumn::create('fileSize') + ->notNull(), + CharDatabaseTableColumn::create('fileHash') + ->length(64) + ->notNull(), + VarcharDatabaseTableColumn::create('fileExtension') + ->length(10) + ->notNull(), + CharDatabaseTableColumn::create('secret') + ->length(32) + ->notNull(), + IntDatabaseTableColumn::create('objectTypeID'), + NotNullVarchar255DatabaseTableColumn::create('mimeType'), + IntDatabaseTableColumn::create('width'), + IntDatabaseTableColumn::create('height'), + CharDatabaseTableColumn::create('fileHashWebp') + ->length(64), + ]) + ->indices([ + DatabaseTablePrimaryIndex::create() + ->columns(['fileID']), + ]) + ->foreignKeys([ + DatabaseTableForeignKey::create() + ->columns(['objectTypeID']) + ->referencedTable('wcf1_object_type') + ->referencedColumns(['objectTypeID']) + ->onDelete('SET NULL'), + ]), + DatabaseTable::create('wcf1_file_temporary') + ->columns([ + CharDatabaseTableColumn::create('identifier') + ->length(40) + ->notNull(), + NotNullInt10DatabaseTableColumn::create('time'), + NotNullVarchar255DatabaseTableColumn::create('filename'), + BigintDatabaseTableColumn::create('fileSize') + ->notNull(), + CharDatabaseTableColumn::create('fileHash') + ->length(64) + ->notNull(), + VarcharDatabaseTableColumn::create('fileExtension') + ->length(10) + ->notNull(), + CharDatabaseTableColumn::create('secret') + ->length(32) + ->notNull(), + IntDatabaseTableColumn::create('objectTypeID'), + TextDatabaseTableColumn::create('context'), + VarbinaryDatabaseTableColumn::create('chunks') + ->length(255) + ->notNull(), + ]) + ->indices([ + DatabaseTablePrimaryIndex::create() + ->columns(['identifier']), ]) + ->foreignKeys([ + DatabaseTableForeignKey::create() + ->columns(['objectTypeID']) + ->referencedTable('wcf1_object_type') + ->referencedColumns(['objectTypeID']) + ->onDelete('SET NULL'), + ]), + DatabaseTable::create('wcf1_file_thumbnail') + ->columns([ + ObjectIdDatabaseTableColumn::create('thumbnailID'), + NotNullInt10DatabaseTableColumn::create('fileID'), + VarcharDatabaseTableColumn::create('identifier') + ->length(50) + ->notNull(), + CharDatabaseTableColumn::create('fileHash') + ->length(64) + ->notNull(), + VarcharDatabaseTableColumn::create('fileExtension') + ->length(10) + ->notNull(), + IntDatabaseTableColumn::create('width') + ->notNull(), + IntDatabaseTableColumn::create('height') + ->notNull(), + CharDatabaseTableColumn::create('formatChecksum') + ->length(12), + ]) + ->indices([ + DatabaseTablePrimaryIndex::create() + ->columns(['thumbnailID']), + ]) + ->foreignKeys([ + DatabaseTableForeignKey::create() + ->columns(['fileID']) + ->referencedTable('wcf1_file') + ->referencedColumns(['fileID']) + ->onDelete('CASCADE'), + ]), ]; diff --git a/wcfsetup/install/files/lib/data/file/temporary/FileTemporary.class.php b/wcfsetup/install/files/lib/data/file/temporary/FileTemporary.class.php index b2dc1d5567..0b5a4bfd4a 100644 --- a/wcfsetup/install/files/lib/data/file/temporary/FileTemporary.class.php +++ b/wcfsetup/install/files/lib/data/file/temporary/FileTemporary.class.php @@ -13,7 +13,7 @@ use wcf\util\JSON; * @since 6.1 * * @property-read string $identifier - * @property-read int|null $time + * @property-read int $time * @property-read string $filename * @property-read int $fileSize * @property-read string $fileHash diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index faa9ae33d5..727af3850e 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -610,13 +610,13 @@ CREATE TABLE wcf1_file ( mimeType VARCHAR(255) NOT NULL, width INT, height INT, - fileHashWebp CHAR(64), + fileHashWebp CHAR(64) ); DROP TABLE IF EXISTS wcf1_file_temporary; CREATE TABLE wcf1_file_temporary ( identifier CHAR(40) NOT NULL PRIMARY KEY, - time INT, + time INT NOT NULL, filename VARCHAR(255) NOT NULL, fileSize BIGINT NOT NULL, fileHash CHAR(64) NOT NULL, -- 2.20.1