Open dsebastien opened 1 year ago
Schema::create('user_resource_interactions', function (Blueprint $table) {
$table->id();
$table->string('cuid')->unique()->index();
// If the user is deleted, then this is deleted as well
$table->foreignId('user_id')->nullable()->constrained()->cascadeOnDelete();
// If the global resource is deleted, then this is deleted as well
$table->foreignId('resource_id')->constrained()->cascadeOnDelete();
$table->boolean('hidden')->default(false);
$table->boolean('explored')->default(false);
$table->boolean('starred')->default(false);
$table->boolean('upvoted')->default(false);
$table->boolean('downvoted')->default(false);
$table->boolean('reported')->default(false);
$table->timestamps();
$table->unique(['user_id', 'resource_id']);
});
Schema::dropIfExists('user_resource_interactions');
WARNING: the schema must be reviewed to take into account the fact that different communities might tag the same resources differently. A separation might be required between local and global tags.
Schema::create('tags', function (Blueprint $table) {
$table->id();
$table->string('cuid')->unique()->index();
$table->string('name')->unique();
$table->string('slug')->unique()->index();
$table->timestamps();
});
Schema::dropIfExists('tags');
Schema::create('resource_tag', function (Blueprint $table) {
$table->id();
$table->string('cuid')->unique()->index();
// if the global resource is deleted, then this is deleted as well
$table->foreignId('resource_id')->constrained()->cascadeOnDelete();
// If the global tag is deleted, then this is deleted as well
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
$table->timestamps();
$table->unique(['resource_id', 'tag_id']);
});
Schema::dropIfExists('resource_tag');
Schema::create('keywords', function (Blueprint $table) {
$table->id();
$table->string('cuid')->unique()->index();
$table->string('name')->unique();
$table->string('slug')->unique()->index();
$table->timestamps();
});
Schema::dropIfExists('keywords');
Schema::create('resource_keyword', function (Blueprint $table) {
$table->id();
$table->string('cuid')->unique()->index();
// If the global resource is deleted, then this is deleted as well
$table->foreignId('resource_id')->constrained()->cascadeOnDelete();
// If the global keyword is deleted, then this is deleted as well
$table->foreignId('keyword_id')->constrained()->cascadeOnDelete();
$table->timestamps();
$table->unique(['resource_id', 'keyword_id']);
});
Schema::dropIfExists('resource_keyword');
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('cuid')->unique()->index();
$table->string('name')->unique();
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->foreignId('parent_id')->nullable()->constrained('categories')->nullOnDelete();
$table->timestamps();
});
Schema::dropIfExists('categories');
Schema::create('resource_category', function (Blueprint $table) {
$table->id();
$table->string('cuid')->unique()->index();
// If the global resource is deleted, then this is deleted as well
$table->foreignId('resource_id')->constrained()->cascadeOnDelete();
// If the global category is deleted, then this is deleted as well
$table->foreignId('category_id')->constrained()->cascadeOnDelete();
$table->timestamps();
$table->unique(['resource_id', 'category_id']);
});
Schema::dropIfExists('resource_category');
Schema::create('resource_user_profile', static function (Blueprint $table) {
$table->id();
$table->string('cuid')->unique()->index();
// If the global resource is deleted, then this is deleted as well
$table->foreignId('resource_id')->constrained()->cascadeOnDelete();
// If the user profile is deleted, then this is deleted as well
$table->foreignId('user_profile_id')->constrained('user_profiles')->cascadeOnDelete();
$table->boolean('is_curator')->default(false)->index();
$table->boolean('is_author')->default(false)->index();
$table->boolean('is_contributor')->default(false)->index();
$table->boolean('is_editor')->default(false)->index();
$table->boolean('is_reviewer')->default(false)->index();
$table->boolean('is_creator')->default(false)->index();
$table->timestamps();
$table->unique(['resource_id', 'user_profile_id']);
});
Schema::dropIfExists('resource_user_profile');
User profiles
Users
Communities
Settings (billing, etc)
User Summaries
Conversations
Organizations
Files:
Audio
Scientific articles
Books
Videos
Podcasts
Podcast episodes
Newsletters
Newsletter editions
X tweets
X threads
Quotes
RSS feeds
Job Listings