Squashed Laravel Migrations

This commit is contained in:
Jérémy Munsch 2022-05-24 10:43:06 +02:00
parent 40c38fa7d6
commit c031281345
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC
29 changed files with 266 additions and 1105 deletions

View file

@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->integer('role')->default(2);
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProjects extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('projects', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('projects');
}
}

View file

@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTickets extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('tickets', function (Blueprint $table) {
$table->id();
$table->foreignId('created_by')->constrained('users');
$table->foreignId('project_id')->constrained('projects');
$table->integer('type');
$table->text('text');
$table->string('file')->nullable();
$table->integer('status')->default(1);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tickets');
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->foreignId('project_id')->nullable()->after('role')->constrained('projects');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropConstrainedForeignId('project_id');
});
}
}

View file

@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMessages extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('messages', function (Blueprint $table) {
$table->id();
$table->foreignId('ticket_id')->constrained('tickets');
$table->foreignId('user_id')->nullable()->constrained('users');
$table->text('message');
$table->string('file')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('messages');
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterTickets extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('tickets', function(Blueprint $table) {
$table->string('file2')->nullable()->after('file');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('tickets', function(Blueprint $table) {
$table->dropColumn('file2');
});
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSubscriptions extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->foreignId('ticket_id')->constrained('tickets');
$table->foreignId('user_id')->constrained('users');
$table->primary(['ticket_id', 'user_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('subscriptions');
}
}

View file

@ -1,33 +0,0 @@
<?php
use App\Enums\TicketStatus;
use App\Models\Ticket;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateTicketsStatusWithEnumStatus extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
foreach (Ticket::where('status', 4)->get() as $ticket) {
$ticket->status = TicketStatus::archived();
$ticket->saveQuietly();
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View file

@ -1,41 +0,0 @@
<?php
use App\Enums\TicketStatus;
use App\Models\Ticket;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateTicketsStatusWithEnumStatus2 extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
foreach (Ticket::where('status', 5)->get() as $ticket) {
$ticket->status = TicketStatus::production();
$ticket->saveQuietly();
}
foreach (Ticket::where('status', 4)->get() as $ticket) {
$ticket->status = TicketStatus::recette();
$ticket->saveQuietly();
}
foreach (Ticket::where('status', 3)->get() as $ticket) {
$ticket->status = TicketStatus::processed();
$ticket->saveQuietly();
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View file

@ -1,54 +0,0 @@
<?php
use App\Enums\TicketStatus;
use App\Models\Ticket;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateTicketsStatusWithEnumStatus3 extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//save saveQuietly (without events)
foreach (Ticket::where('status', 9)->get() as $ticket) {
$ticket->status = TicketStatus::archived();
$ticket->saveQuietly();
}
foreach (Ticket::where('status', 6)->get() as $ticket) {
$ticket->status = TicketStatus::production();
$ticket->saveQuietly();
}
foreach (Ticket::where('status', 5)->get() as $ticket) {
$ticket->status = TicketStatus::recette();
$ticket->saveQuietly();
}
foreach (Ticket::where('status', 4)->get() as $ticket) {
$ticket->status = TicketStatus::processed();
$ticket->saveQuietly();
}
foreach (Ticket::where('status', 3)->get() as $ticket) {
$ticket->status = TicketStatus::waiting();
$ticket->saveQuietly();
}
foreach (Ticket::where('status', 2)->get() as $ticket) {
$ticket->status = TicketStatus::inprogress();
$ticket->saveQuietly();
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View file

@ -1,64 +0,0 @@
<?php
use App\Models\User;
use App\Models\SiteUser;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProjectUserTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('project_user', function (Blueprint $table) {
$table->foreignId('project_id')->constrained('projects');
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->unique(['project_id', 'user_id']);
});
/** @var \App\Models\User */
foreach (User::all() as $user) {
if ($user->project_id) {
$uP = new SiteUser();
$uP->project_id = $user->project_id;
$uP->user_id = $user->id;
$uP->saveOrFail();
}
}
Schema::table('users', function (Blueprint $table) {
$table->dropForeign(['project_id']);
$table->dropColumn('project_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->foreignId('project_id')->nullable()
->after('role')->constrained('projects');
});
/** @var \App\Models\SiteUser */
foreach (SiteUser::all() as $uP) {
try {
/** @var \App\Models\User */
$user = User::whereId($uP->user_id)->firstOrFail();
$user->project_id = $uP->project_id;
$user->saveOrFail();
//phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
} catch (ModelNotFoundException $e) {
// ignore
}
}
Schema::dropIfExists('project_user');
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddSoftDeleteOnUsers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddSoftDeleteOnProjects extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('projects', function (Blueprint $table) {
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('projects', function (Blueprint $table) {
$table->dropSoftDeletes();
});
}
}

View file

@ -1,58 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class RenameProjectsTableIntoSitesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::rename('projects', 'sites');
Schema::table('project_user', function (Blueprint $table) {
$table->dropForeign('project_user_project_id_foreign');
$table->dropUnique(['project_id', 'user_id']);
});
Schema::rename('project_user', 'site_user');
Schema::table('site_user', function (Blueprint $table) {
$table->renameColumn('project_id', 'site_id');
$table->foreign('site_id')->references('id')->on('sites');
$table->unique(['site_id', 'user_id']);
});
Schema::table('tickets', function (Blueprint $table) {
$table->dropForeign('tickets_project_id_foreign');
$table->renameColumn('project_id', 'site_id');
$table->foreign('site_id')->references('id')->on('sites');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::rename('sites', 'projects');
Schema::table('site_user', function (Blueprint $table) {
$table->dropForeign('site_user_site_id_foreign');
$table->dropUnique(['site_id', 'user_id']);
});
Schema::rename('site_user', 'project_user');
Schema::table('project_user', function (Blueprint $table) {
$table->renameColumn('site_id', 'project_id');
$table->foreign('project_id')->references('id')->on('projects');
$table->unique(['project_id', 'user_id']);
});
Schema::table('tickets', function (Blueprint $table) {
$table->dropForeign('tickets_site_id_foreign');
$table->renameColumn('site_id', 'project_id');
$table->foreign('project_id')->references('id')->on('projects');
});
}
}

View file

@ -1,35 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProjectsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('projects', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('status');
$table->text('description');
$table->text('todo')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('projects');
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProjectSiteTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('project_site', function (Blueprint $table) {
$table->foreignId('project_id')->constrained('projects')->cascadeOnDelete();
$table->foreignId('site_id')->constrained('sites');
$table->unique(['project_id', 'site_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('project_site');
}
}

View file

@ -1,34 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('logs', function (Blueprint $table) {
$table->id();
$table->text('entry');
$table->foreignId('user_id')->constrained('users');
$table->morphs('parent'); // can be Site or Projet
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('logs');
}
}

View file

@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateFilesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('files', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('uri', 2000)->nullable(); // max uri length is 2k
$table->string('file')->nullable();
$table->smallInteger('type');
$table->smallInteger('category');
$table->morphs('parent'); // can be Site or Projet
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('files');
}
}

View file

@ -1,36 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTodoOnSitesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('sites', function (Blueprint $table) {
$table->string('status')->after('name');
$table->text('description')->after('status');
$table->text('todo')->after('description')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('sites', function (Blueprint $table) {
$table->dropColumn('status');
$table->dropColumn('description');
$table->dropColumn('todo');
});
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePasswordResetsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('password_resets');
}
}

View file

@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateWeekPlanningsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('week_plannings', function (Blueprint $table) {
$table->id();
$table->date('start');
$table->text('planning');
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('week_plannings');
}
}

View file

@ -1,92 +0,0 @@
<?php
use App\Models\Schedule;
use App\Models\WeekPlanning;
use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSchedulesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('schedules', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users');
$table->date('date');
$table->smallInteger('slot');
$table->string('activity')->nullable();
$table->text('description');
$table->bigInteger('id_lie')->nullable();
$table->string('model_lie')->nullable();
$table->timestamps();
$table->unique(['user_id','date','slot'], 'user_day_slot_unique');
});
//migrate data from week plannings
$week_plannings = WeekPlanning::all();
foreach ($week_plannings as $oneweek) {
$user_id = $oneweek->user_id;
$plan = $oneweek->planning;
foreach ($plan as $time => $data) {
$date = Carbon::createFromTimestamp($time);
foreach ($data as $dayslot => $cell) {
$activite = $this->convertColorToType($cell["type"]);
$description = $cell["text"];
$id_objetlie = $cell["foreign"];
$type_objetlie = $cell["cellModel"]; //c'est une table d'après l'Enum CellModel
$collected = [
'user_id' => $user_id,
'date' => $date,
'slot' => $dayslot,
'activity' => $activite,
'description' => $description,
'id_lie' => $id_objetlie,
'model_lie' => $type_objetlie
];
//si activite null et description null ne pas enregistrer
if (!is_null($activite) && !is_null($description)) {
$schedule = new Schedule();
$schedule->fill($collected);
$schedule->save();
}
}
}
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('schedules');
}
/**
* convertir une value de couleur en type
*/
private function convertColorToType($value) {
$converter = array(
'#c6e0b4' => 'support',
'#b4c6e7' => 'rnd',
'#00b0f0' => 'dev',
'#ffe699' => 'projects',
'#f4b084' => 'management',
'#aeaaaa' => 'absence',
'abscence' => 'absence'
);
return $converter[$value] ?? null;
}
}

View file

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIsInternalOnTicketsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('tickets', function (Blueprint $table) {
$table->tinyInteger('is_internal')->default(0)->after('status');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('tickets', function (Blueprint $table) {
$table->dropColumn('is_internal')->default(0);
});
}
}

View file

@ -1,40 +0,0 @@
<?php
use App\Models\Schedule;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class MigrateSchedulesToEightSlotsPerDay extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//migrate data from week plannings
for ($i = 4; $i > 0; $i--) {
$schedules = Schedule::where('slot', $i)->get();
foreach ($schedules as $oneschedule) {
$newschedule = $oneschedule->replicate();
$newschedule->slot = $i * 2;
$newschedule->save();
$oneschedule->slot = ($i * 2) - 1;
$oneschedule->save();
}
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//not reversible
}
}

View file

@ -1,37 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DropWeekPlanningsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('week_plannings');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::create('week_plannings', function (Blueprint $table) {
$table->id();
$table->date('start');
$table->text('planning');
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->timestamps();
});
}
}

View file

@ -1,37 +0,0 @@
<?php
use App\Models\Project;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateMarkersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('macro_markers', function (Blueprint $table) {
$table->id();
$table->string('label')->comment('Le libellé du marqueur.');
$table->dateTime('marker')->comment('Le point dans le temps du marqueur.');
$table->foreignIdFor(Project::class)->constrained()
->onUpdate('cascade')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('macro_markers');
}
}

View file

@ -1,39 +0,0 @@
<?php
use App\Models\Project;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateActivitiesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('macro_activities', function (Blueprint $table) {
$table->id();
$table->dateTime('start')->comment('La date de début de l\'activité.');
$table->dateTime('end')->comment('La date de fin de l\'activité.');
$table->unsignedSmallInteger('activity')->comment('Enum MacroSchedule/Activity');
$table->unsignedSmallInteger('load')->comment('Le nombre d\'hommes qui vont être mobilisé pour la tâche');
$table->string('comment')->comment('Commentaire sur la tâche, (255 chars max)');
$table->foreignIdFor(Project::class)->constrained()
->onUpdate('cascade')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('macro_activities');
}
}

View file

@ -1,35 +0,0 @@
<?php
use App\Models\Project;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class ChangeStatusOnProjectsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Project::query()->update(['status' => '0']);
Schema::table('projects', function (Blueprint $table) {
$table->unsignedSmallInteger('status')->default(0)
->comment('Enum ProjectStatus')->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('projects', function (Blueprint $table) {
$table->string('status')->default('')->change();
});
}
}

View file

@ -0,0 +1,266 @@
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `files`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `files` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`uri` varchar(2000) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`file` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`type` smallint(6) NOT NULL,
`category` smallint(6) NOT NULL,
`parent_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`parent_id` bigint(20) unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `files_parent_type_parent_id_index` (`parent_type`,`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `logs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `logs` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`entry` text COLLATE utf8mb4_unicode_ci NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`parent_type` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`parent_id` bigint(20) unsigned NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `logs_user_id_foreign` (`user_id`),
KEY `logs_parent_type_parent_id_index` (`parent_type`,`parent_id`),
CONSTRAINT `logs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `macro_activities`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `macro_activities` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`start` datetime NOT NULL COMMENT 'La date de début de l''activité.',
`end` datetime NOT NULL COMMENT 'La date de fin de l''activité.',
`activity` smallint(5) unsigned NOT NULL COMMENT 'Enum MacroSchedule/Activity',
`load` smallint(5) unsigned NOT NULL COMMENT 'Le nombre d''hommes qui vont être mobilisé pour la tâche',
`comment` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Commentaire sur la tâche, (255 chars max)',
`project_id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `macro_activities_project_id_foreign` (`project_id`),
CONSTRAINT `macro_activities_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `macro_markers`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `macro_markers` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`label` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'Le libellé du marqueur.',
`marker` datetime NOT NULL COMMENT 'Le point dans le temps du marqueur.',
`project_id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `macro_markers_project_id_foreign` (`project_id`),
CONSTRAINT `macro_markers_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `messages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `messages` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`ticket_id` bigint(20) unsigned NOT NULL,
`user_id` bigint(20) unsigned DEFAULT NULL,
`message` text COLLATE utf8mb4_unicode_ci NOT NULL,
`file` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `messages_ticket_id_foreign` (`ticket_id`),
KEY `messages_user_id_foreign` (`user_id`),
CONSTRAINT `messages_ticket_id_foreign` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`),
CONSTRAINT `messages_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `migrations`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `migrations` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`migration` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`batch` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `password_resets`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `password_resets` (
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`token` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
KEY `password_resets_email_index` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `project_site`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `project_site` (
`project_id` bigint(20) unsigned NOT NULL,
`site_id` bigint(20) unsigned NOT NULL,
UNIQUE KEY `project_site_project_id_site_id_unique` (`project_id`,`site_id`),
KEY `project_site_site_id_foreign` (`site_id`),
CONSTRAINT `project_site_project_id_foreign` FOREIGN KEY (`project_id`) REFERENCES `projects` (`id`) ON DELETE CASCADE,
CONSTRAINT `project_site_site_id_foreign` FOREIGN KEY (`site_id`) REFERENCES `sites` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `projects`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `projects` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` smallint(5) unsigned NOT NULL DEFAULT 0 COMMENT 'Enum ProjectStatus',
`description` text COLLATE utf8mb4_unicode_ci NOT NULL,
`todo` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `schedules`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `schedules` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) unsigned NOT NULL,
`date` date NOT NULL,
`slot` smallint(6) NOT NULL,
`activity` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`description` text COLLATE utf8mb4_unicode_ci NOT NULL,
`id_lie` bigint(20) DEFAULT NULL,
`model_lie` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_day_slot_unique` (`user_id`,`date`,`slot`),
CONSTRAINT `schedules_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `site_user`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `site_user` (
`site_id` bigint(20) unsigned NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
UNIQUE KEY `site_user_site_id_user_id_unique` (`site_id`,`user_id`),
KEY `project_user_user_id_foreign` (`user_id`),
CONSTRAINT `project_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
CONSTRAINT `site_user_site_id_foreign` FOREIGN KEY (`site_id`) REFERENCES `sites` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `sites`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `sites` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`status` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`description` text COLLATE utf8mb4_unicode_ci NOT NULL,
`todo` text COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `subscriptions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `subscriptions` (
`ticket_id` bigint(20) unsigned NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`ticket_id`,`user_id`),
KEY `subscriptions_user_id_foreign` (`user_id`),
CONSTRAINT `subscriptions_ticket_id_foreign` FOREIGN KEY (`ticket_id`) REFERENCES `tickets` (`id`),
CONSTRAINT `subscriptions_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `tickets`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tickets` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_by` bigint(20) unsigned NOT NULL,
`site_id` bigint(20) unsigned NOT NULL,
`type` int(11) NOT NULL,
`text` text COLLATE utf8mb4_unicode_ci NOT NULL,
`file` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`file2` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`status` int(11) NOT NULL DEFAULT 1,
`is_internal` tinyint(4) NOT NULL DEFAULT 0,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `tickets_created_by_foreign` (`created_by`),
KEY `tickets_project_id_foreign` (`site_id`),
CONSTRAINT `tickets_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`),
CONSTRAINT `tickets_site_id_foreign` FOREIGN KEY (`site_id`) REFERENCES `sites` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`role` int(11) NOT NULL DEFAULT 2,
`remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
`deleted_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
INSERT INTO `migrations` VALUES (1,'2014_10_12_000000_create_users_table',1);
INSERT INTO `migrations` VALUES (2,'2020_11_13_152248_create_projects',1);
INSERT INTO `migrations` VALUES (3,'2020_11_13_152321_create_tickets',1);
INSERT INTO `migrations` VALUES (4,'2020_11_17_140637_update_users',1);
INSERT INTO `migrations` VALUES (5,'2020_11_25_104931_create_messages',2);
INSERT INTO `migrations` VALUES (6,'2020_11_25_141438_alter_tickets',2);
INSERT INTO `migrations` VALUES (7,'2020_11_26_132557_create_subscriptions',3);
INSERT INTO `migrations` VALUES (8,'2021_04_21_132132_update_tickets_status_with_enum_status',4);
INSERT INTO `migrations` VALUES (9,'2021_04_21_132140_update_tickets_status_with_enum_status2',5);
INSERT INTO `migrations` VALUES (10,'2021_04_21_132140_update_tickets_status_with_enum_status3',6);
INSERT INTO `migrations` VALUES (11,'2021_06_17_173912_create_project_user_table',7);
INSERT INTO `migrations` VALUES (12,'2021_06_28_163754_add_soft_delete_on_users',8);
INSERT INTO `migrations` VALUES (13,'2021_06_28_163755_add_soft_delete_on_projects',9);
INSERT INTO `migrations` VALUES (14,'2021_07_23_111336_rename_projects_table_into_sites_table',10);
INSERT INTO `migrations` VALUES (15,'2021_07_23_150120_create_projects_table',11);
INSERT INTO `migrations` VALUES (16,'2021_07_23_152102_create_project_site_table',12);
INSERT INTO `migrations` VALUES (17,'2021_07_23_152810_create_logs_table',13);
INSERT INTO `migrations` VALUES (18,'2021_07_23_153446_create_files_table',14);
INSERT INTO `migrations` VALUES (19,'2021_07_27_144557_add_todo_on_sites_table',15);
INSERT INTO `migrations` VALUES (20,'2021_08_01_140823_create_password_resets_table',16);
INSERT INTO `migrations` VALUES (21,'2021_10_01_090053_create_week_plannings_table',17);
INSERT INTO `migrations` VALUES (22,'2021_12_03_195755_create_schedules_table',18);
INSERT INTO `migrations` VALUES (23,'2022_02_23_121545_add_is_internal_on_tickets_table',19);
INSERT INTO `migrations` VALUES (24,'2022_03_08_101614_migrate_schedules_to_eight_slots_per_day',20);
INSERT INTO `migrations` VALUES (25,'2022_03_15_164122_drop_week_plannings_table',21);
INSERT INTO `migrations` VALUES (26,'2022_04_26_095605_create_markers_table',22);
INSERT INTO `migrations` VALUES (27,'2022_04_26_095636_create_activities_table',23);
INSERT INTO `migrations` VALUES (28,'2022_04_26_102155_change_status_on_projects_table',24);