diff --git a/database/migrations/2019_01_03_154432_create_site_user_pivot_table.php b/database/migrations/2019_01_03_154432_create_site_user_pivot_table.php deleted file mode 100644 index 937f226..0000000 --- a/database/migrations/2019_01_03_154432_create_site_user_pivot_table.php +++ /dev/null @@ -1,41 +0,0 @@ -dropPrimary('site_id'); - // $table->integer('id')->unsigned()->first()->autoIncrement(); - // $table->primary('id'); - // $table->engine = 'InnoDB'; - // }); - - Schema::create('site_user', function (Blueprint $table) { - $table->integer('user_id')->unsigned()->nullable(); - $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); - $table->integer('site_id')->unsigned()->nullable(); - $table->foreign('site_id')->references('id')->on('site')->onDelete('cascade'); - $table->primary(['site_id', 'user_id']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('site_user'); - } -} diff --git a/database/migrations/2019_01_07_103109_add_fields_to_sites_table.php b/database/migrations/2019_01_07_103109_add_fields_to_sites_table.php deleted file mode 100644 index 6548a2d..0000000 --- a/database/migrations/2019_01_07_103109_add_fields_to_sites_table.php +++ /dev/null @@ -1,34 +0,0 @@ -string('site_rcs', 100)->nullable(); - $table->string('site_libelle', 200)->nullable(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('site', function (Blueprint $table) { - $table->dropColumn('site_rcs'); - $table->dropColumn('site_libelle'); - }); - } -} diff --git a/database/migrations/2019_01_08_094821_add_diffusiondatefield_to_coupons_table.php b/database/migrations/2019_01_08_094821_add_diffusiondatefield_to_coupons_table.php deleted file mode 100644 index bda1e98..0000000 --- a/database/migrations/2019_01_08_094821_add_diffusiondatefield_to_coupons_table.php +++ /dev/null @@ -1,40 +0,0 @@ -date('coupon_maxdatediffusion')->nullable(); - $table->string('coupon_products_image', 500)->nullable(); - $table->string('coupon_validity_text', 500)->nullable(); - $table->string('coupon_legal_mentions', 500)->nullable(); - $table->dropColumn('coupon_quantity'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('coupon', function (Blueprint $table) { - $table->integer('coupon_quantity'); - $table->dropColumn('coupon_maxdatediffusion'); - $table->dropColumn('coupon_products_image'); - $table->dropColumn('coupon_validity_text'); - $table->dropColumn('coupon_legal_mentions'); - }); - } -} diff --git a/database/migrations/2019_01_09_132916_create_campagne_coupon_pivot_table.php b/database/migrations/2019_01_09_132916_create_campagne_coupon_pivot_table.php deleted file mode 100644 index 060aca3..0000000 --- a/database/migrations/2019_01_09_132916_create_campagne_coupon_pivot_table.php +++ /dev/null @@ -1,33 +0,0 @@ -integer('camp_id')->nullable(); - $table->foreign('camp_id')->references('camp_id')->on('campagne')->onDelete('cascade'); - $table->integer('coupon_id')->nullable(); - $table->foreign('coupon_id')->references('coupon_id')->on('coupon')->onDelete('cascade'); - $table->primary(['camp_id', 'coupon_id']); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::drop('campagne_coupon'); - } -} diff --git a/database/migrations/2019_02_27_133440_add_treatmentcenter_to_coupons.php b/database/migrations/2019_02_27_133440_add_treatmentcenter_to_coupons.php deleted file mode 100644 index b14841f..0000000 --- a/database/migrations/2019_02_27_133440_add_treatmentcenter_to_coupons.php +++ /dev/null @@ -1,32 +0,0 @@ -integer('coupon_treatment_center')->default(1); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::table('coupon', function (Blueprint $table) { - $table->dropColumn('coupon_treatment_center'); - }); - } -} diff --git a/database/migrations/2025_03_23_113215_create_jobs_table.php b/database/migrations/2025_03_23_113215_create_jobs_table.php deleted file mode 100644 index 1be9e8a..0000000 --- a/database/migrations/2025_03_23_113215_create_jobs_table.php +++ /dev/null @@ -1,36 +0,0 @@ -bigIncrements('id'); - $table->string('queue')->index(); - $table->longText('payload'); - $table->unsignedTinyInteger('attempts'); - $table->unsignedInteger('reserved_at')->nullable(); - $table->unsignedInteger('available_at'); - $table->unsignedInteger('created_at'); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('jobs'); - } -} diff --git a/database/migrations/2025_03_23_113522_create_failed_jobs_table.php b/database/migrations/2025_03_23_113522_create_failed_jobs_table.php deleted file mode 100644 index 6aa6d74..0000000 --- a/database/migrations/2025_03_23_113522_create_failed_jobs_table.php +++ /dev/null @@ -1,36 +0,0 @@ -id(); - $table->string('uuid')->unique(); - $table->text('connection'); - $table->text('queue'); - $table->longText('payload'); - $table->longText('exception'); - $table->timestamp('failed_at')->useCurrent(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('failed_jobs'); - } -} diff --git a/database/migrations/2025_03_26_124019_move_uploaded_files_to_build_folder.php b/database/migrations/2025_03_26_124019_move_uploaded_files_to_build_folder.php deleted file mode 100644 index a149fe4..0000000 --- a/database/migrations/2025_03_26_124019_move_uploaded_files_to_build_folder.php +++ /dev/null @@ -1,85 +0,0 @@ -withTrashed()->get(); - foreach ($couponModels as $couponModel) { - $couponModel->coupon_gs1code = self::getUpdatedFilePath($couponModel->coupon_gs1code ?? ''); - $couponModel->coupon_thumbnail1 = self::getUpdatedFilePath($couponModel->coupon_thumbnail1 ?? ''); - $couponModel->coupon_thumbnail2 = self::getUpdatedFilePath($couponModel->coupon_thumbnail2 ?? ''); - $couponModel->coupon_thumbnail3 = self::getUpdatedFilePath($couponModel->coupon_thumbnail3 ?? ''); - $couponModel->coupon_thumbnail4 = self::getUpdatedFilePath($couponModel->coupon_thumbnail4 ?? ''); - $couponModel->coupon_image = self::getUpdatedFilePath($couponModel->coupon_image ?? ''); - $couponModel->coupon_decoration_image = self::getUpdatedFilePath($couponModel->coupon_decoration_image ?? ''); - $couponModel->coupon_logo_image = self::getUpdatedFilePath($couponModel->coupon_logo_image ?? ''); - $couponModel->save(); - } - - $siteModels = Site::query()->get(); - foreach ($siteModels as $siteModel) { - $siteModel->site_logo = self::getUpdatedFilePath($siteModel->site_logo ?? '',); - $siteModel->save(); - } - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - $couponModels = Coupon::query()->withTrashed()->get(); - foreach ($couponModels as $couponModel) { - $couponModel->coupon_gs1code = self::getOldFilePath($couponModel->coupon_gs1code ?? ''); - $couponModel->coupon_thumbnail1 = self::getOldFilePath($couponModel->coupon_thumbnail1 ?? ''); - $couponModel->coupon_thumbnail2 = self::getOldFilePath($couponModel->coupon_thumbnail2 ?? ''); - $couponModel->coupon_thumbnail3 = self::getOldFilePath($couponModel->coupon_thumbnail3 ?? ''); - $couponModel->coupon_thumbnail4 = self::getOldFilePath($couponModel->coupon_thumbnail4 ?? ''); - $couponModel->coupon_image = self::getOldFilePath($couponModel->coupon_image ?? ''); - $couponModel->coupon_decoration_image = self::getOldFilePath($couponModel->coupon_decoration_image ?? ''); - $couponModel->coupon_logo_image = self::getOldFilePath($couponModel->coupon_logo_image ?? ''); - $couponModel->save(); - } - - $siteModels = Site::query()->get(); - foreach ($siteModels as $siteModel) { - $siteModel->site_logo = self::getOldFilePath($siteModel->site_logo ?? '',); - $siteModel->save(); - } - } - - /** - * Get the updated file path (with 'storage/modelfiles' instead of folder in public) - * @param string $path - * - * @return string - */ - private static function getUpdatedFilePath(string $path): string - { - return !empty($path) ? Str::start($path, 'storage/modelfiles/') : ''; - } - - /** - * Get the old file path (with 'uploads/images' instead of 'storage/modelfiles') - * @param string $path - * - * @return string - */ - private static function getOldFilePath(string $path): string - { - return Str::replaceFirst('storage/modelfiles/', '', $path); - } -} diff --git a/database/migrations/2025_04_11_100847_create_calendrier_table.php b/database/migrations/2025_04_11_100847_create_calendrier_table.php new file mode 100644 index 0000000..1dfb9f5 --- /dev/null +++ b/database/migrations/2025_04_11_100847_create_calendrier_table.php @@ -0,0 +1,34 @@ +integer('calendrier_id', true); + $table->integer('calendrier_couponId')->default(0); + $table->timestamp('calendrier_startdate')->default(DB::raw("'1970-01-01 00:00:01'")); + $table->timestamp('calendrier_enddate')->default(DB::raw("'1970-01-01 00:00:01'")); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('calendrier'); + } +}; diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2025_04_11_100847_create_campagne_coupon_table.php similarity index 52% rename from database/migrations/2014_10_12_100000_create_password_resets_table.php rename to database/migrations/2025_04_11_100847_create_campagne_coupon_table.php index 0d5cb84..de170b5 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2025_04_11_100847_create_campagne_coupon_table.php @@ -1,10 +1,10 @@ string('email')->index(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); + Schema::create('campagne_coupon', function (Blueprint $table) { + $table->integer('campagne_id'); + $table->integer('coup_id')->index('campagne_coupon_coupon_id_foreign'); + + $table->primary(['campagne_id', 'coup_id']); }); } @@ -27,6 +28,6 @@ class CreatePasswordResetsTable extends Migration */ public function down() { - Schema::dropIfExists('password_resets'); + Schema::dropIfExists('campagne_coupon'); } -} +}; diff --git a/database/migrations/2025_04_11_100847_create_campagne_table.php b/database/migrations/2025_04_11_100847_create_campagne_table.php new file mode 100644 index 0000000..7ddfe52 --- /dev/null +++ b/database/migrations/2025_04_11_100847_create_campagne_table.php @@ -0,0 +1,38 @@ +integer('camp_id', true); + $table->string('camp_siteId', 50); + $table->string('camp_name', 500)->default(''); + $table->integer('camp_type')->default(0)->comment('0 = mur; 1 = panier; 2 = mur sous forme de panier'); + $table->integer('camp_limitedPrinting')->default(0)->comment('Limite l\'impression des paniers à un BR à la fois'); + $table->integer('camp_published')->default(1); + $table->timestamp('camp_createdate')->useCurrent(); + $table->timestamp('camp_updatedate')->useCurrentOnUpdate()->useCurrent(); + $table->timestamp('camp_deleted_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('campagne'); + } +}; diff --git a/database/migrations/2025_04_11_100847_create_contact_table.php b/database/migrations/2025_04_11_100847_create_contact_table.php new file mode 100644 index 0000000..6cf80c7 --- /dev/null +++ b/database/migrations/2025_04_11_100847_create_contact_table.php @@ -0,0 +1,44 @@ +integer('contact_id', true); + $table->string('contact_siteId', 50); + $table->string('contact_ref', 200)->default(''); + $table->string('contact_prenom', 200)->default(''); + $table->string('contact_nom', 200)->default(''); + $table->string('contact_email', 200)->default(''); + $table->string('contact_cp', 50)->default(''); + $table->string('contact_ville', 200)->default(''); + $table->timestamp('contact_createdate')->useCurrent(); + $table->timestamp('contact_updatedate')->useCurrentOnUpdate()->useCurrent(); + $table->unsignedInteger('contact_country')->default(250); + $table->string('contact_hash', 50)->nullable()->unique('contact_hash'); + + $table->index(['contact_ref', 'contact_email'], 'contact_ref'); + $table->index(['contact_email', 'contact_ref'], 'contact_email'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('contact'); + } +}; diff --git a/database/migrations/2025_04_11_100847_create_coupon_table.php b/database/migrations/2025_04_11_100847_create_coupon_table.php new file mode 100644 index 0000000..0169cd4 --- /dev/null +++ b/database/migrations/2025_04_11_100847_create_coupon_table.php @@ -0,0 +1,62 @@ +integer('coupon_id', true); + $table->integer('coupon_siteId'); + $table->string('coupon_code', 50)->default(''); + $table->string('coupon_gs1code', 500)->default(''); + $table->string('coupon_name', 500)->default(''); + $table->float('coupon_value', 10, 0)->default(0); + $table->string('coupon_thumbnail1', 500)->default(''); + $table->string('coupon_thumbnail2', 500)->default(''); + $table->string('coupon_thumbnail3', 500)->default(''); + $table->string('coupon_thumbnail4', 500)->default(''); + $table->string('coupon_image', 500)->default(''); + $table->integer('coupon_enablelimitquantity')->default(0); + $table->integer('coupon_limitquantity')->default(1); + $table->integer('coupon_enablelimitperiod')->default(0); + $table->integer('coupon_limitperiod')->default(0); + $table->integer('coupon_validity')->default(30); + $table->date('coupon_mindatediffusion')->nullable(); + $table->date('coupon_maxdatediffusion')->nullable(); + $table->date('coupon_maxdatevalidity')->nullable(); + $table->integer('coupon_norme')->default(0)->comment('0 = par défaut; 1 = Benelux'); + $table->integer('coupon_published')->default(1); + $table->timestamp('coupon_createdate')->useCurrent(); + $table->timestamp('coupon_updatedate')->useCurrentOnUpdate()->nullable()->useCurrent(); + $table->timestamp('coupon_deleted_at')->nullable(); + $table->string('coupon_decoration_image', 500)->nullable(); + $table->string('coupon_logo_image', 500)->nullable(); + $table->string('coupon_validity_text', 500)->nullable(); + $table->string('coupon_rcs', 500)->nullable(); + $table->string('coupon_legal_mentions', 1000)->nullable(); + $table->tinyInteger('coupon_legal_mentions_splitted')->default(0); + $table->string('coupon_site_contact', 500)->nullable(); + $table->unsignedInteger('coupon_seuil_alert')->default(100); + $table->integer('coupon_treatment_center')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('coupon'); + } +}; diff --git a/database/migrations/2021_04_20_105237_create_customers_table.php b/database/migrations/2025_04_11_100847_create_customers_table.php similarity index 63% rename from database/migrations/2021_04_20_105237_create_customers_table.php rename to database/migrations/2025_04_11_100847_create_customers_table.php index 44b9882..0985d62 100644 --- a/database/migrations/2021_04_20_105237_create_customers_table.php +++ b/database/migrations/2025_04_11_100847_create_customers_table.php @@ -1,10 +1,10 @@ increments('id'); - $table->string('hashcode', 36)->unique(); - $table->string('email')->unique(); - $table->integer('country')->default('250'); + $table->bigInteger('id', true); + $table->string('hashcode', 36)->default(''); + $table->string('email'); + $table->integer('country')->default(250); $table->timestamps(); + + $table->unique(['hashcode', 'email'], 'crm_id'); }); } @@ -31,4 +33,4 @@ class CreateCustomersTable extends Migration { Schema::dropIfExists('customers'); } -} +}; diff --git a/database/migrations/2019_02_19_105641_create_logs_table.php b/database/migrations/2025_04_11_100847_create_logs_table.php similarity index 81% rename from database/migrations/2019_02_19_105641_create_logs_table.php rename to database/migrations/2025_04_11_100847_create_logs_table.php index 31bb828..91dbdb5 100644 --- a/database/migrations/2019_02_19_105641_create_logs_table.php +++ b/database/migrations/2025_04_11_100847_create_logs_table.php @@ -1,10 +1,10 @@ increments('id'); $table->integer('log_action'); $table->string('log_refsite')->nullable(); - $table->integer('log_contactId')->nullable(); + $table->integer('log_contactId')->nullable()->index('FK_log_contact'); $table->string('log_source'); $table->text('log_params')->nullable(); $table->string('log_statut'); $table->text('log_message'); - $table->timestamp('created_at'); + $table->timestamp('created_at')->useCurrent(); }); } + /** * Reverse the migrations. * @@ -34,4 +35,4 @@ class CreateLogsTable extends Migration { Schema::dropIfExists('logs'); } -} +}; diff --git a/database/migrations/2018_09_27_074409_create_mouvements_table.php b/database/migrations/2025_04_11_100847_create_mouvement_table.php similarity index 64% rename from database/migrations/2018_09_27_074409_create_mouvements_table.php rename to database/migrations/2025_04_11_100847_create_mouvement_table.php index 6bb1e5e..1306448 100644 --- a/database/migrations/2018_09_27_074409_create_mouvements_table.php +++ b/database/migrations/2025_04_11_100847_create_mouvement_table.php @@ -1,10 +1,10 @@ engine = 'MyISAM'; $table->increments('mouvement_id'); $table->unsignedInteger('mouvement_couponId'); - $table->string('mouvement_type', 50); - $table->timestamp('mouvement_created_at'); - $table->unsignedInteger('mouvement_nombre'); - $table->string('mouvement_commentaire', 255)->nullable(); + $table->integer('mouvement_nombre'); + $table->string('mouvement_commentaire')->nullable(); + $table->timestamp('mouvement_created_at')->useCurrentOnUpdate()->useCurrent(); }); } @@ -33,4 +31,4 @@ class CreateMouvementsTable extends Migration { Schema::dropIfExists('mouvement'); } -} +}; diff --git a/database/migrations/2025_04_11_100847_create_mur_table.php b/database/migrations/2025_04_11_100847_create_mur_table.php new file mode 100644 index 0000000..df0b772 --- /dev/null +++ b/database/migrations/2025_04_11_100847_create_mur_table.php @@ -0,0 +1,35 @@ +integer('mur_id', true); + $table->integer('mur_campId')->index('FK_mur_campagne'); + $table->integer('mur_contactId')->index('mur_contactId'); + $table->integer('mur_couponId')->index('mur_couponId'); + $table->integer('mur_deleted')->default(0); + $table->timestamp('mur_createdate')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('mur'); + } +}; diff --git a/database/migrations/2019_02_14_095700_add_name_to_notifications.php b/database/migrations/2025_04_11_100847_create_notification_table.php similarity index 58% rename from database/migrations/2019_02_14_095700_add_name_to_notifications.php rename to database/migrations/2025_04_11_100847_create_notification_table.php index 7e114d9..c588a4a 100644 --- a/database/migrations/2019_02_14_095700_add_name_to_notifications.php +++ b/database/migrations/2025_04_11_100847_create_notification_table.php @@ -1,10 +1,10 @@ integer('notif_id', true); + $table->string('notif_email', 200)->default(''); + $table->integer('notif_campId'); $table->string('notif_name', 100)->nullable(); }); } @@ -25,8 +28,6 @@ class AddNameToNotifications extends Migration */ public function down() { - Schema::table('notification', function (Blueprint $table) { - $table->dropColumn('notif_name'); - }); + Schema::dropIfExists('notification'); } -} +}; diff --git a/database/migrations/2025_04_11_100847_create_panier_content_table.php b/database/migrations/2025_04_11_100847_create_panier_content_table.php new file mode 100644 index 0000000..533a41b --- /dev/null +++ b/database/migrations/2025_04_11_100847_create_panier_content_table.php @@ -0,0 +1,34 @@ +integer('panier_content_id', true); + $table->integer('panier_content_panierId')->default(0)->index('FK_panier_content_panier'); + $table->integer('panier_content_couponId'); + $table->integer('panier_content_quantity')->default(0); + $table->integer('panier_content_printed')->default(0); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('panier_content'); + } +}; diff --git a/database/migrations/2025_04_11_100847_create_panier_table.php b/database/migrations/2025_04_11_100847_create_panier_table.php new file mode 100644 index 0000000..147eaac --- /dev/null +++ b/database/migrations/2025_04_11_100847_create_panier_table.php @@ -0,0 +1,36 @@ +integer('panier_id', true); + $table->string('panier_ref', 100)->default(''); + $table->integer('panier_campId'); + $table->integer('panier_contactId')->index('FK_panier_contact'); + $table->integer('panier_pending')->default(1)->comment('1 = en cours; 0 = terminé'); + $table->timestamp('panier_createdate')->useCurrent(); + $table->timestamp('panier_updatedate')->useCurrentOnUpdate()->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('panier'); + } +}; diff --git a/database/migrations/2025_04_03_095449_delete_password_resets_table.php b/database/migrations/2025_04_11_100847_create_password_resets_table.php similarity index 92% rename from database/migrations/2025_04_03_095449_delete_password_resets_table.php rename to database/migrations/2025_04_11_100847_create_password_resets_table.php index d4ae8ed..fcacb80 100644 --- a/database/migrations/2025_04_03_095449_delete_password_resets_table.php +++ b/database/migrations/2025_04_11_100847_create_password_resets_table.php @@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class DeletePasswordResetsTable extends Migration +return new class extends Migration { /** * Run the migrations. @@ -13,7 +13,11 @@ class DeletePasswordResetsTable extends Migration */ public function up() { - Schema::dropIfExists('password_resets'); + Schema::create('password_resets', function (Blueprint $table) { + $table->string('email')->index(); + $table->string('token'); + $table->timestamp('created_at')->nullable(); + }); } /** @@ -23,10 +27,6 @@ class DeletePasswordResetsTable extends Migration */ public function down() { - Schema::create('password_resets', function (Blueprint $table) { - $table->string('email')->index(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); + Schema::dropIfExists('password_resets'); } -} +}; diff --git a/database/migrations/2025_04_11_100847_create_printed_walls_table.php b/database/migrations/2025_04_11_100847_create_printed_walls_table.php new file mode 100644 index 0000000..951d93c --- /dev/null +++ b/database/migrations/2025_04_11_100847_create_printed_walls_table.php @@ -0,0 +1,33 @@ +integer('camp_id')->index('FK_printed_wall_campagne'); + $table->integer('coupon_id')->index('FK_printed_wall_coupon'); + $table->bigInteger('customer_id')->index('FK_printed_wall_customers'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('printed_walls'); + } +}; diff --git a/database/migrations/2025_04_11_100847_create_site_table.php b/database/migrations/2025_04_11_100847_create_site_table.php new file mode 100644 index 0000000..aa41a3f --- /dev/null +++ b/database/migrations/2025_04_11_100847_create_site_table.php @@ -0,0 +1,38 @@ +increments('id'); + $table->string('site_id', 50); + $table->string('site_nom', 200)->default(''); + $table->string('site_logo', 500)->default(''); + $table->string('site_contact', 500)->default(''); + $table->string('site_rcs', 100)->nullable(); + $table->string('site_libelle', 200)->nullable(); + $table->string('crm_token')->nullable(); + $table->string('crm_password')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('site'); + } +}; diff --git a/database/migrations/2019_01_02_110900_add_roles_to_users_table.php b/database/migrations/2025_04_11_100847_create_site_user_table.php similarity index 52% rename from database/migrations/2019_01_02_110900_add_roles_to_users_table.php rename to database/migrations/2025_04_11_100847_create_site_user_table.php index 8fb6554..9364faf 100644 --- a/database/migrations/2019_01_02_110900_add_roles_to_users_table.php +++ b/database/migrations/2025_04_11_100847_create_site_user_table.php @@ -1,10 +1,10 @@ text('roles')->nullable(); + Schema::create('site_user', function (Blueprint $table) { + $table->unsignedInteger('user_id')->index('site_user_user_id_foreign'); + $table->unsignedInteger('site_id'); + + $table->primary(['site_id', 'user_id']); }); } @@ -25,8 +28,6 @@ class AddRolesToUsersTable extends Migration */ public function down() { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('roles'); - }); + Schema::dropIfExists('site_user'); } -} +}; diff --git a/database/migrations/2019_02_14_111618_create_statistiques_table.php b/database/migrations/2025_04_11_100847_create_statistiques_table.php similarity index 75% rename from database/migrations/2019_02_14_111618_create_statistiques_table.php rename to database/migrations/2025_04_11_100847_create_statistiques_table.php index a6f48b8..0abeea4 100644 --- a/database/migrations/2019_02_14_111618_create_statistiques_table.php +++ b/database/migrations/2025_04_11_100847_create_statistiques_table.php @@ -1,10 +1,10 @@ increments('id'); - $table->string('stat_campId'); - $table->string('stat_couponId'); + $table->integer('stat_campId'); + $table->integer('stat_couponId'); $table->integer('stat_couponPrinted'); - $table->timestamp('created_at'); + $table->timestamp('created_at')->useCurrent(); }); } @@ -31,4 +31,4 @@ class CreateStatistiquesTable extends Migration { Schema::dropIfExists('statistiques'); } -} +}; diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2025_04_11_100847_create_users_table.php similarity index 84% rename from database/migrations/2014_10_12_000000_create_users_table.php rename to database/migrations/2025_04_11_100847_create_users_table.php index 58bebbe..d9bede1 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2025_04_11_100847_create_users_table.php @@ -1,10 +1,10 @@ increments('id'); $table->string('name'); - $table->string('email'); + $table->string('email', 100)->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); $table->timestamps(); + $table->text('roles')->nullable(); }); } @@ -33,4 +34,4 @@ class CreateUsersTable extends Migration { Schema::dropIfExists('users'); } -} +}; diff --git a/database/migrations/2025_04_11_100850_add_foreign_keys_to_campagne_coupon_table.php b/database/migrations/2025_04_11_100850_add_foreign_keys_to_campagne_coupon_table.php new file mode 100644 index 0000000..c1a783c --- /dev/null +++ b/database/migrations/2025_04_11_100850_add_foreign_keys_to_campagne_coupon_table.php @@ -0,0 +1,34 @@ +foreign(['campagne_id'], 'campagne_coupon_camp_id_foreign')->references(['camp_id'])->on('campagne')->onDelete('CASCADE'); + $table->foreign(['coup_id'], 'campagne_coupon_coupon_id_foreign')->references(['coupon_id'])->on('coupon')->onDelete('CASCADE'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('campagne_coupon', function (Blueprint $table) { + $table->dropForeign('campagne_coupon_camp_id_foreign'); + $table->dropForeign('campagne_coupon_coupon_id_foreign'); + }); + } +}; diff --git a/database/migrations/2019_02_14_083641_add_seuil_to_coupons.php b/database/migrations/2025_04_11_100850_add_foreign_keys_to_logs_table.php similarity index 52% rename from database/migrations/2019_02_14_083641_add_seuil_to_coupons.php rename to database/migrations/2025_04_11_100850_add_foreign_keys_to_logs_table.php index 3fed9bb..1862fd1 100644 --- a/database/migrations/2019_02_14_083641_add_seuil_to_coupons.php +++ b/database/migrations/2025_04_11_100850_add_foreign_keys_to_logs_table.php @@ -1,10 +1,10 @@ unsignedInteger('coupon_seuil_alert')->default(100); + Schema::table('logs', function (Blueprint $table) { + $table->foreign(['log_contactId'], 'FK_log_contact')->references(['contact_id'])->on('contact')->onDelete('CASCADE'); }); } @@ -25,8 +25,8 @@ class AddSeuilToCoupons extends Migration */ public function down() { - Schema::table('coupon', function (Blueprint $table) { - $table->dropColumn('coupon_seuil_alert'); + Schema::table('logs', function (Blueprint $table) { + $table->dropForeign('FK_log_contact'); }); } -} +}; diff --git a/database/migrations/2019_01_10_083318_add_countryfield_to_contact_table.php b/database/migrations/2025_04_11_100850_add_foreign_keys_to_mur_table.php similarity index 53% rename from database/migrations/2019_01_10_083318_add_countryfield_to_contact_table.php rename to database/migrations/2025_04_11_100850_add_foreign_keys_to_mur_table.php index 8123a69..b0d2083 100644 --- a/database/migrations/2019_01_10_083318_add_countryfield_to_contact_table.php +++ b/database/migrations/2025_04_11_100850_add_foreign_keys_to_mur_table.php @@ -1,10 +1,10 @@ unsignedInteger('contact_country')->default(250); + Schema::table('mur', function (Blueprint $table) { + $table->foreign(['mur_contactId'], 'FK_mur_contact')->references(['contact_id'])->on('contact')->onDelete('CASCADE'); }); } @@ -25,8 +25,8 @@ class AddCountryfieldToContactTable extends Migration */ public function down() { - Schema::table('contact', function (Blueprint $table) { - $table->dropColumn('contact_country'); + Schema::table('mur', function (Blueprint $table) { + $table->dropForeign('FK_mur_contact'); }); } -} +}; diff --git a/database/migrations/2025_04_11_100850_add_foreign_keys_to_panier_content_table.php b/database/migrations/2025_04_11_100850_add_foreign_keys_to_panier_content_table.php new file mode 100644 index 0000000..0e7443e --- /dev/null +++ b/database/migrations/2025_04_11_100850_add_foreign_keys_to_panier_content_table.php @@ -0,0 +1,32 @@ +foreign(['panier_content_panierId'], 'FK_panier_content_panier')->references(['panier_id'])->on('panier')->onDelete('CASCADE'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('panier_content', function (Blueprint $table) { + $table->dropForeign('FK_panier_content_panier'); + }); + } +}; diff --git a/database/migrations/2018_09_27_125349_add_soft_delete.php b/database/migrations/2025_04_11_100850_add_foreign_keys_to_panier_table.php similarity index 52% rename from database/migrations/2018_09_27_125349_add_soft_delete.php rename to database/migrations/2025_04_11_100850_add_foreign_keys_to_panier_table.php index a7eea63..4156734 100644 --- a/database/migrations/2018_09_27_125349_add_soft_delete.php +++ b/database/migrations/2025_04_11_100850_add_foreign_keys_to_panier_table.php @@ -1,10 +1,10 @@ softDeletes('camp_deleted_at'); + Schema::table('panier', function (Blueprint $table) { + $table->foreign(['panier_contactId'], 'FK_panier_contact')->references(['contact_id'])->on('contact')->onDelete('CASCADE'); }); } @@ -25,8 +25,8 @@ class AddSoftDelete extends Migration */ public function down() { - Schema::table('campagne', function (Blueprint $table) { - // + Schema::table('panier', function (Blueprint $table) { + $table->dropForeign('FK_panier_contact'); }); } -} +}; diff --git a/database/migrations/2025_04_11_100850_add_foreign_keys_to_printed_walls_table.php b/database/migrations/2025_04_11_100850_add_foreign_keys_to_printed_walls_table.php new file mode 100644 index 0000000..c4b8624 --- /dev/null +++ b/database/migrations/2025_04_11_100850_add_foreign_keys_to_printed_walls_table.php @@ -0,0 +1,36 @@ +foreign(['camp_id'], 'FK_printed_wall_campagne')->references(['camp_id'])->on('campagne'); + $table->foreign(['coupon_id'], 'FK_printed_wall_coupon')->references(['coupon_id'])->on('coupon'); + $table->foreign(['customer_id'], 'FK_printed_wall_customers')->references(['id'])->on('customers')->onDelete('CASCADE'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('printed_walls', function (Blueprint $table) { + $table->dropForeign('FK_printed_wall_campagne'); + $table->dropForeign('FK_printed_wall_coupon'); + $table->dropForeign('FK_printed_wall_customers'); + }); + } +}; diff --git a/database/migrations/2025_04_11_100850_add_foreign_keys_to_site_user_table.php b/database/migrations/2025_04_11_100850_add_foreign_keys_to_site_user_table.php new file mode 100644 index 0000000..a0282d7 --- /dev/null +++ b/database/migrations/2025_04_11_100850_add_foreign_keys_to_site_user_table.php @@ -0,0 +1,34 @@ +foreign(['site_id'])->references(['id'])->on('site')->onDelete('CASCADE'); + $table->foreign(['user_id'])->references(['id'])->on('users')->onDelete('CASCADE'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('site_user', function (Blueprint $table) { + $table->dropForeign('site_user_site_id_foreign'); + $table->dropForeign('site_user_user_id_foreign'); + }); + } +};