Changeset View
Standalone View
src/database/migrations/2022_03_02_100000_create_filesystem_tables.php
- This file was added.
<?php | |||||
use Illuminate\Database\Migrations\Migration; | |||||
use Illuminate\Database\Schema\Blueprint; | |||||
use Illuminate\Support\Facades\Schema; | |||||
return new class extends Migration | |||||
{ | |||||
/** | |||||
* Run the migrations. | |||||
*/ | |||||
public function up(): void | |||||
{ | |||||
Schema::create( | |||||
'fs_items', | |||||
function (Blueprint $table) { | |||||
vanmeeuwen: fs_items, so we may introduce a column fs_type (bitflip);
Example (very speculative):
1… | |||||
$table->string('id', 36)->primary(); | |||||
$table->bigInteger('user_id')->index(); | |||||
$table->integer('type')->unsigned()->default(0); | |||||
Not Done Inline Actionsshould be in fs_attributes, with an observer that updates this column (because it is what we have to list touching as few tables as possible) vanmeeuwen: should be in fs_attributes, with an observer that updates this column (because it is what we… | |||||
$table->timestamps(); | |||||
Not Done Inline Actionsnot needed here, fs_attributes vanmeeuwen: not needed here, fs_attributes | |||||
$table->softDeletes(); | |||||
Not Done Inline Actionsnot needed here, fs_attributes vanmeeuwen: not needed here, fs_attributes | |||||
$table->foreign('user_id')->references('id')->on('users') | |||||
->onUpdate('cascade')->onDelete('cascade'); | |||||
Not Done Inline Actionsthis table can also use softDeletes() vanmeeuwen: this table can also use softDeletes() | |||||
} | |||||
); | |||||
Not Done Inline Actionsadditional index on user_id vanmeeuwen: additional index on user_id | |||||
Schema::create( | |||||
'fs_properties', | |||||
function (Blueprint $table) { | |||||
$table->bigIncrements('id'); | |||||
$table->string('item_id', 36); | |||||
$table->string('key')->index(); | |||||
Not Done Inline Actionsmoves to fs_attributes as key-value almost like a settings trait vanmeeuwen: moves to fs_attributes as key-value almost like a settings trait | |||||
Not Done Inline ActionsIn that case I would just store the share link in the attribute since we don't really need the permission at this point. mollekopf: In that case I would just store the share link in the attribute since we don't really need the… | |||||
$table->text('value'); | |||||
$table->timestamps(); | |||||
$table->unique(['item_id', 'key']); | |||||
$table->foreign('item_id')->references('id')->on('fs_items') | |||||
->onDelete('cascade')->onUpdate('cascade'); | |||||
} | |||||
); | |||||
Schema::create( | |||||
'fs_chunks', | |||||
function (Blueprint $table) { | |||||
$table->bigIncrements('id'); | |||||
$table->string('item_id', 36); | |||||
$table->string('chunk_id', 36); | |||||
$table->integer('sequence')->default(0); | |||||
Not Done Inline Actionsif the terminology in upload and download is "chunking" (i don't know that it is), then let's name this fs_chunks vanmeeuwen: if the terminology in upload and download is "chunking" (i don't know that it is), then let's… | |||||
$table->integer('size')->unsigned()->default(0); | |||||
Not Done Inline Actionsdoesn't need an id column vanmeeuwen: doesn't need an id column | |||||
$table->timestamps(); | |||||
Not Done Inline Actionsadditional columns chunk_id (string, 36) and sequence_id for ordering vanmeeuwen: additional columns chunk_id (string, 36) and sequence_id for ordering | |||||
Not Done Inline Actionsthe chunk_id seems superfluous as file_id + sequence_id would already be unique. mollekopf: the chunk_id seems superfluous as file_id + sequence_id would already be unique. | |||||
$table->softDeletes(); | |||||
$table->unique(['item_id', 'chunk_id']); | |||||
// $table->unique(['item_id', 'sequence', 'deleted_at']); | |||||
$table->foreign('item_id')->references('id')->on('fs_items') | |||||
->onUpdate('cascade')->onDelete('cascade'); | |||||
} | |||||
); | |||||
Not Done Inline Actionsremove beta- prefix vanmeeuwen: remove beta- prefix | |||||
if (!\App\Sku::where('title', 'files')->first()) { | |||||
\App\Sku::create([ | |||||
'title' => 'files', | |||||
'name' => 'File storage', | |||||
'description' => 'Access to file storage', | |||||
'cost' => 0, | |||||
Not Done Inline Actionsremove \Beta from namespace vanmeeuwen: remove `\Beta` from namespace | |||||
'units_free' => 0, | |||||
'period' => 'monthly', | |||||
'handler_class' => 'App\Handlers\Files', | |||||
'active' => true, | |||||
]); | |||||
} | |||||
} | |||||
/** | |||||
* Reverse the migrations. | |||||
*/ | |||||
public function down(): void | |||||
{ | |||||
Schema::dropIfExists('fs_properties'); | |||||
Schema::dropIfExists('fs_chunks'); | |||||
Schema::dropIfExists('fs_items'); | |||||
} | |||||
}; |
fs_items, so we may introduce a column fs_type (bitflip);
Example (very speculative):
1 - regular file
2 - regular directory
4 - directory with photo album
8 - directory with backups
16 - directory with documents
32 - archived directory
64 - shared (basically allowing us to draw attention to it?)
128 - AES encrypted
256 - ?? etc.
meaning that fs_type == 36 contains some really old photos, and fs_type == 100 means you have it shared probably with some family members.