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( | |||||
'libraries', | |||||
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'); | |||||
$table->string('name')->nullable(); | |||||
$table->timestamp('created_at')->useCurrent(); | |||||
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->timestamp('updated_at')->useCurrent(); | |||||
Not Done Inline Actionsnot needed here, fs_attributes vanmeeuwen: not needed here, fs_attributes | |||||
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( | |||||
'files', | |||||
function (Blueprint $table) { | |||||
$table->string('id', 36)->primary(); | |||||
$table->string('library_id', 36); | |||||
$table->string('name', 512); | |||||
$table->bigInteger('size')->unsigned()->default(0); | |||||
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->string('mimetype'); | |||||
// $table->text('metadata')->nullable(); | |||||
$table->timestamp('created_at')->useCurrent(); | |||||
$table->timestamp('updated_at')->useCurrent(); | |||||
$table->unique(['library_id', 'name']); | |||||
$table->foreign('library_id')->references('id')->on('libraries') | |||||
->onUpdate('cascade')->onDelete('cascade'); | |||||
} | |||||
); | |||||
Schema::create( | |||||
'file_permissions', | |||||
function (Blueprint $table) { | |||||
$table->bigIncrements('id'); | |||||
$table->string('file_id', 36); | |||||
// FIXME: Maybe instead of 'user', it would be better to name it 'who', or 'identifier' or? | |||||
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->string('user')->index(); | |||||
$table->smallInteger('permissions')->unsigned()->default(0); | |||||
Not Done Inline Actionsdoesn't need an id column vanmeeuwen: doesn't need an id column | |||||
$table->timestamp('created_at')->useCurrent(); | |||||
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->timestamp('updated_at')->useCurrent(); | |||||
$table->unique(['file_id', 'user']); | |||||
$table->foreign('file_id')->references('id')->on('files') | |||||
->onUpdate('cascade')->onDelete('cascade'); | |||||
} | |||||
); | |||||
} | |||||
Not Done Inline Actionsremove beta- prefix vanmeeuwen: remove beta- prefix | |||||
/** | |||||
* Reverse the migrations. | |||||
*/ | |||||
public function down(): void | |||||
{ | |||||
Schema::dropIfExists('file_permissions'); | |||||
Not Done Inline Actionsremove \Beta from namespace vanmeeuwen: remove `\Beta` from namespace | |||||
Schema::dropIfExists('files'); | |||||
Schema::dropIfExists('libraries'); | |||||
} | |||||
}; |
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.