Add the SQL structure to the DDL PIP
authorAlexander Ebert <ebert@woltlab.com>
Sun, 2 Jun 2024 11:16:51 +0000 (13:16 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 8 Jun 2024 10:20:25 +0000 (12:20 +0200)
wcfsetup/install/files/acp/database/update_com.woltlab.wcf_6.1.php
wcfsetup/install/files/lib/data/file/temporary/FileTemporary.class.php
wcfsetup/setup/db/install.sql

index 26e50c3d5fb1e67a53eefec2c5f145cd74d73a3b..988e920e3a6e0110b2f026fecf9177f99934f122 100644 (file)
@@ -8,13 +8,21 @@
  * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  */
 
+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'),
+        ]),
 ];
index b2dc1d55676730116cc3eaada5f2a1173e59c1d9..0b5a4bfd4ab58e6560e7593d70caee3fa3bccd1c 100644 (file)
@@ -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
index faa9ae33d562136615f1f62a92c9f627a5b1d3c0..727af3850ef9ebd554285fe09c5d0af8261ab8a1 100644 (file)
@@ -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,