condense backend migrations
This commit is contained in:
parent
7c65c3b8c6
commit
4d05a1541e
4 changed files with 10 additions and 63 deletions
|
|
@ -35,6 +35,15 @@ intentionally omitted here - update this section as entities land.
|
|||
`new Set(...)`) instead of creating them through their fake
|
||||
repositories
|
||||
|
||||
## Migrations
|
||||
|
||||
- This project is not in production. By default, schema changes should update
|
||||
the relevant create-table migration so migrations describe the current desired
|
||||
schema from scratch.
|
||||
- Do not add alter-table or data-backfill migrations unless the user explicitly
|
||||
asks for production-style migration safety.
|
||||
- Put seed data in seeders, not migrations.
|
||||
|
||||
## PHP rules
|
||||
|
||||
- Imports: always put `use` statements at the top of the file, never use
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ return new class extends Migration
|
|||
$table->id();
|
||||
$table->foreignId('set_id')->constrained('sets');
|
||||
$table->string('title');
|
||||
$table->text('description')->default('');
|
||||
$table->foreignId('parent_element_id')
|
||||
->nullable()
|
||||
->constrained('elements');
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('elements', function (Blueprint $table) {
|
||||
$table->text('description')->default('');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('elements', function (Blueprint $table) {
|
||||
$table->dropColumn('description');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$descriptionsByTitle = [
|
||||
'Baderech HaAvodah' => 'Baderech HaAvodah is a way of living - '
|
||||
. 'a structured path for inner and outer growth, '
|
||||
. 'spiritual refinement, and personal development.',
|
||||
'Avodah Foundations' => 'Core foundations for building a steady '
|
||||
. 'avodah practice.',
|
||||
'Daily Practice' => 'Practical steps for consistent daily growth.',
|
||||
];
|
||||
|
||||
foreach ($descriptionsByTitle as $title => $description) {
|
||||
DB::table('elements')
|
||||
->where('title', $title)
|
||||
->where('description', '')
|
||||
->update(['description' => $description]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$titles = [
|
||||
'Baderech HaAvodah',
|
||||
'Avodah Foundations',
|
||||
'Daily Practice',
|
||||
];
|
||||
|
||||
foreach ($titles as $title) {
|
||||
DB::table('elements')
|
||||
->where('title', $title)
|
||||
->update(['description' => '']);
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue