Create migrations + some Cleanup code

This commit is contained in:
Jérémy Munsch 2022-03-09 10:54:00 +01:00
parent cd86d67b77
commit 1c0f225afa
No known key found for this signature in database
GPG key ID: 55196BEE445F6049
26 changed files with 662 additions and 124 deletions

View file

@ -66,7 +66,7 @@ class ImportMoba extends Command
$code_boite = $data[0];
$code_ede = $data[1];
// format dans le fichier Y-m-d
$date_ponte = $data[2];
$date_de_ponte = $data[2];
$code_produit = $data[3];
$libelle_produit = $data[4];
$lot_externe = $data[5];
@ -77,13 +77,13 @@ class ImportMoba extends Command
$moba = new Moba();
$moba->code_boite = $code_boite;
$moba->code_ede = $code_ede;
$moba->date_ponte = $date_ponte;
$moba->date_de_ponte = $date_de_ponte;
$moba->code_produit = $code_produit;
$moba->libelle_produit = $libelle_produit;
$moba->lot_externe = $lot_externe;
$moba->dcr = $dcr;
$moba->date_emballage = $date_emballage;
$moba->ean13 = $ean;
$moba->ean_13 = $ean;
$moba->save();
$lines++;

View file

@ -53,8 +53,8 @@ class MajEleveurs extends Command
}
$line++;
$code_boite = $data[0];
$ean13 = $data[7];
$mobas = Moba::where('code_boite', '=', $code_boite)->andWhere('ean13', '=', '')->update(['ean13' => $data[7]]);
$ean_13 = $data[7];
$mobas = Moba::where('code_boite', '=', $code_boite)->andWhere('ean_13', '=', '')->update(['ean_13' => $data[7]]);
echo $line . "\n\r";
}
}

View file

@ -6,7 +6,7 @@ use Illuminate\Http\Request;
use App\Models\MiseEnPlace;
use App\Models\Aliment;
use App\Models\Eleveur;
use App\Models\Moba;
use App\TracaOeuf;
use Carbon\Carbon;
class AjaxController extends Controller
@ -76,7 +76,7 @@ class AjaxController extends Controller
} else {
if (strpos($data[7], "/") !== false && strpos($data[8], "/") !== false) {
$mep = new MiseEnPlace();
$mep->eleveurId_pondeuse = $eleveur->id;
$mep->eleveur_id = $eleveur->id;
$mep->code_lot_pondeuse = $data[6];
$mep->hectares_parcours_pondeuse = $data[20];
switch ($data[21]) {
@ -159,7 +159,7 @@ class AjaxController extends Controller
$year = $dateCarbon['year'];
$dcr = $year . '-' . $month . '-' . $day;
$moba = Moba::where(['code_ede' => $code, 'dcr' => $dcr])->orderBy('id', 'DESC')->first();
$moba = TracaOeuf::where(['code_ede' => $code, 'dcr' => $dcr])->orderBy('id', 'DESC')->first();
if (!$moba) {
return redirect()->route('erreur404');

View file

@ -7,16 +7,6 @@ use Illuminate\Foundation\Auth\ConfirmsPasswords;
class ConfirmPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Confirm Password Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password confirmations and
| uses a simple trait to include the behavior. You're free to explore
| this trait and override any functions that require customization.
|
*/
use ConfirmsPasswords;
/**

View file

@ -7,15 +7,5 @@ use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
}

View file

@ -7,16 +7,6 @@ use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
@ -36,7 +26,12 @@ class LoginController extends Controller
$this->middleware('guest')->except('logout');
}
public function username()
/**
* Get user name column
*
* @return string
*/
public function username(): string
{
return 'username';
}

View file

@ -3,23 +3,13 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\User;
use App\Models\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**

View file

@ -7,16 +7,6 @@ use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**

View file

@ -7,16 +7,6 @@ use Illuminate\Foundation\Auth\VerifiesEmails;
class VerificationController extends Controller
{
/*
|--------------------------------------------------------------------------
| Email Verification Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling email verification for any
| user that recently registered with the application. Emails may also
| be re-sent if the user didn't receive the original email message.
|
*/
use VerifiesEmails;
/**

View file

@ -4,7 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Eleveur;
use App\Http\Requests\MyRequest;
use Response;
use Illuminate\Support\Facades\Response;
class EleveurController extends Controller
{
@ -174,7 +174,7 @@ class EleveurController extends Controller
$callback = function () use ($eleveurs, $columns) {
$file = fopen('php://output', 'w');
fputs($file, "\xEF\xBB\xBF");
// use BOM for Office
// * use BOM for Office
fputcsv($file, $columns, ";");
foreach ($eleveurs as $eleveur) {

View file

@ -6,6 +6,7 @@ use App\Models\Eleveur;
use App\Models\Aliment;
use App\Models\MiseEnPlace;
use App\Models\Moba;
use App\TracaOeuf;
use App\VisuelLibelle;
use Carbon\Carbon;
@ -14,7 +15,7 @@ class FrontController extends Controller
public function indexId($id)
{
$multiple = false;
$mobas = Moba::where('code_boite', $id)->orderBy('id', 'DESC')->first();
$mobas = TracaOeuf::where('code_boite', $id)->orderBy('id', 'DESC')->first();
if (!$mobas) {
return redirect('/search');
@ -22,7 +23,7 @@ class FrontController extends Controller
$edes = $mobas->code_edes;
// check if Bio or not
// * check if Bio or not
$code_ede = $mobas->code_ede;
$code_prod = substr($code_ede, 0, 1);
@ -32,10 +33,10 @@ class FrontController extends Controller
session(['subColor' => 'blue']);
}
$datePonte = $mobas->date_ponte;
$datePonte = $mobas->date_de_ponte;
$dcr = $mobas->dcr;
$date_emballage = $mobas->date_emballage;
// Compare DCR et Today
// * Compare DCR et Today
$date_dcr = Carbon::createFromFormat('Y-m-d', $dcr);
$date_today = Carbon::now();
$dcrGood = $date_today < $date_dcr;
@ -52,14 +53,14 @@ class FrontController extends Controller
$elevId = $eleveurs->pluck('id');
$mep = MiseEnPlace::whereIn('eleveurId_pondeuse', $elevId)->where('date_transfert_poulettes', '<', $datePonte)->orderBy('id', 'DESC')->first();
$mep = MiseEnPlace::whereIn('eleveur_id', $elevId)->where('date_transfert_poulettes', '<', $datePonte)->orderBy('id', 'DESC')->first();
if ($mep) {
$aliment = Aliment::where('code_lot', $mep->code_lot_pondeuse)->orderBy('id', 'DESC')->first();
} else {
$mep = '';
$aliment = "";
}
$dataVisuel = VisuelLibelle::where('ean13', $mobas->ean13)->first();
$dataVisuel = VisuelLibelle::where('ean_13', $mobas->ean_13)->first();
return view('themes.loue.index_id', [
'id' => $id,

View file

@ -13,18 +13,13 @@ class MiseEnPlace extends Model
*/
public $timestamps = false;
/**
* @var string
*/
protected $table = 'mise_en_place';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'eleveurId_pondeuse',
'eleveur_id',
'code_lot_pondeuse',
'hectares_parcours_pondeuse',
'presence_ruche_pondeuse',

View file

@ -1,17 +0,0 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Moba extends Model
{
public $timestamps = false;
protected $table = 'moba';
public function getCodeEdesAttribute()
{
return Moba::select('code_ede')->where('code_boite', $this->code_boite)->distinct()->get()->pluck('code_ede');
}
}

28
app/Models/TracaOeuf.php Normal file
View file

@ -0,0 +1,28 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
class TracaOeuf extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = false;
/**
* Accessor codes EDE attribute
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getCodeEdesAttribute(): Collection
{
return self::select('code_ede')
->where('code_boite', $this->code_boite)
->distinct()->get()->pluck('code_ede');
}
}

View file

@ -0,0 +1,15 @@
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class TracaVolaille extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var boolean
*/
public $timestamps = false;
}

View file

@ -6,5 +6,4 @@ use Illuminate\Database\Eloquent\Model;
class VisuelLibelle extends Model
{
protected $table = 'visuels_libelles';
}

View file

@ -13,15 +13,18 @@ class CreateUsersTable extends Migration
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
if (!Schema::hasTable('users')) {
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('username')->unique();
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
}
/**

View file

@ -13,11 +13,13 @@ class CreatePasswordResetsTable extends Migration
*/
public function up()
{
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
if (!Schema::hasTable('users')) {
Schema::create('password_resets', function (Blueprint $table) {
$table->string('email')->index();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
}
/**

View file

@ -13,14 +13,16 @@ class CreateFailedJobsTable extends Migration
*/
public function up()
{
Schema::create('failed_jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
if (!Schema::hasTable('users')) {
Schema::create('failed_jobs', function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
}
}
/**

View file

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('users')) {
Schema::create('jobs', function (Blueprint $table) {
$table->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');
}
}

View file

@ -0,0 +1,52 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreateAlimentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement(
'ALTER TABLE `aliments` CHANGE COLUMN `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;'
);
if (!Schema::hasTable('aliments')) {
Schema::create('aliments', function (Blueprint $table) {
$table->id();
$table->string('code_lot', 50)->nullable()
->comment('Code du lot d\'aliment');
$table->date('date_livraison')->nullable()
->comment('Date de livraison de l\'aliment');
$table->string('type_aliment', 50)->nullable()
->comment('le type de l\'aliment');
});
} else {
Schema::table('aliments', function (Blueprint $table) {
$table->string('code_lot', 50)->nullable()
->comment('Code du lot d\'aliment')->change();
$table->date('date_livraison')->nullable()
->comment('Date de livraison de l\'aliment')->change();
$table->string('type_aliment', 50)->nullable()
->comment('le type de l\'aliment')->change();
});
} //end if
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('aliments');
}
}

View file

@ -0,0 +1,159 @@
<?php
use App\Models\Eleveur;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreateEleveursTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('aliments')) {
Schema::create('eleveurs', function (Blueprint $table) {
$table->id();
$table->string('code_cafel', 100)->nullable()
->comment('Code CAFEL de l\'éleveur');
$table->string('code_ede', 100)
->comment('Code EDE de l\'éleveur');
// TODO: replace this with kwaadpepper/enum.
$table->unsignedTinyInteger('civilite')->default(0)
->comment('Civilité de l\'éleveur, enum Civility');
$table->string('nom')
->comment('Nom de l\'éleveur');
$table->string('prenom')
->comment('Prénom de l\'éleveur');
$table->date('naissance')
->comment('Date de naissance de l\'éleveur');
$table->unsignedMediumInteger('cp')
->comment('Code postal de l\'éleveur');
$table->string('ville')
->comment('Ville de l\'éleveur');
$table->date('elv_date_debut')->nullable()
->comment('Date de début d\'activité de l\'éleveur');
$table->string('code_inuav', 10)
->comment('Code INUAV de l\'éleveur (élevage)');
$table->text('exploitation')->nullable()
->comment('Description de l\'exploitation de l\'éleveur');
$table->text('aboutyou')->nullable()
->comment('À propos de l\'éleveur');
$table->text('vocation')->nullable()
->comment('À propos de la vocation de l\'éleveur');
$table->text('likeinjob')->nullable()
->comment('L\'atrait de l\'éleveur pour son métier');
$table->text('loue_means')->nullable()
->comment('Description de la marque par l\'éleveur');
$table->string('path_photo1')->nullable()
->comment('Photo 1 de l\'éleveur');
$table->string('path_photo2')->nullable()
->comment('Photo 2 de l\'éleveur');
$table->string('marquage_oeuf', 12)->nullable()
->comment('Marquage sur l\'oeuf de l\'éleveur');
$table->string('marquage_b1', 14)->nullable()
->comment('Marquage sur l\'oeuf de l\'éleveur');
$table->string('marquage_b2', 14)->nullable()
->comment('Marquage sur l\'oeuf de l\'éleveur');
// * Deleted_at column.
$table->softDeletes();
});
} else {
Schema::table('mise_en_place', function (Blueprint $table) {
$table->dropForeign('FK_mise_en_place_eleveurs');
});
DB::statement(
'ALTER TABLE `eleveurs` CHANGE COLUMN `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;'
);
$eleveurs = Eleveur::all(['id', 'civilite', 'cp', 'elv_date_debut', 'naissance']);
Schema::table('eleveurs', function (Blueprint $table) {
$table->string('code_cafel', 100)->nullable()
->comment('Code CAFEL de l\'éleveur')->change();
$table->string('code_ede', 100)
->comment('Code EDE de l\'éleveur')->change();
$table->string('nom')
->comment('Nom de l\'éleveur')->change();
$table->string('prenom')
->comment('Prénom de l\'éleveur')->change();
$table->string('ville')
->comment('Ville de l\'éleveur')->change();
$table->string('code_inuav', 10)
->comment('Code INUAV de l\'éleveur (élevage)')->change();
$table->text('exploitation')->nullable()
->comment('Description de l\'exploitation de l\'éleveur')->change();
$table->text('aboutyou')->nullable()
->comment('À propos de l\'éleveur')->change();
$table->text('vocation')->nullable()
->comment('À propos de la vocation de l\'éleveur')->change();
$table->text('likeinjob')->nullable()
->comment('L\'atrait de l\'éleveur pour son métier')->change();
$table->text('loue_means')->nullable()
->comment('Description de la marque par l\'éleveur')->change();
$table->string('path_photo1')->nullable()
->comment('Photo 1 de l\'éleveur')->change();
$table->string('path_photo2')->nullable()
->comment('Photo 2 de l\'éleveur')->change();
$table->string('marquage_oeuf', 12)->nullable()
->comment('Marquage sur l\'oeuf de l\'éleveur')->change();
$table->string('marquage_b1', 14)->nullable()
->comment('Marquage sur l\'oeuf de l\'éleveur')->change();
$table->string('marquage_b2', 14)->nullable()
->comment('Marquage sur l\'oeuf de l\'éleveur')->change();
});
Schema::table('eleveurs', function (Blueprint $table) {
$table->dropColumn(['naissance']);
$table->dropColumn(['civilite']);
$table->dropColumn(['cp']);
$table->dropColumn(['elv_date_debut']);
});
Schema::table('eleveurs', function (Blueprint $table) {
$table->unsignedTinyInteger('civilite')->default(0)
->comment('Civilité de l\'éleveur, enum Civility')
->after('code_ede');
$table->date('naissance')->default('2000/01/01')
->comment('Date de naissance de l\'éleveur')
->after('prenom');
$table->unsignedMediumInteger('cp')->default(0)
->comment('Code postal de l\'éleveur')
->after('naissance');
$table->date('elv_date_debut')->nullable()
->comment('Date de début d\'activité de l\'éleveur')
->after('ville');
});
$eleveurs->map(function (Eleveur $eleveur) {
$eleveur->naissance = Carbon::createFromFormat('d/m/Y', $eleveur->naissance);
$eleveur->elv_date_debut = Carbon::createFromFormat('d/m/Y', strlen($eleveur->elv_date_debut) ?
$eleveur->elv_date_debut : '01/01/2000');
$eleveur->civilite = intval($eleveur->civilite);
$eleveur->cp = intval($eleveur->cp);
$eleveur->saveOrFail();
});
} //end if
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('eleveurs');
}
}

View file

@ -0,0 +1,99 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreateTracaOeufsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('moba')) {
Schema::rename('moba', 'traca_oeufs');
}
if (!Schema::hasTable('traca_oeufs')) {
Schema::create('traca_oeufs', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('code_boite')
->index()
->comment('Le code de la boite d\'oeufs xs:integer [0-9]{9}|[0-9]{10}');
$table->string('code_ede', 10)
->index()
->comment('Le code EDE xs:string length 8');
$table->string('code_produit', 14)
->comment('Le code produit xs:string [0-9]{8}.[0-9]{3}');
$table->string('libelle_produit', 38)
->comment('Le libellé du produit xs:string length 35');
$table->unsignedBigInteger('lot_externe')
->index()
->comment('Pas de description xs:integer [0-9]{6}|[0-9]{12}');
$table->unsignedBigInteger('ean_13')
->index()
->comment('Pas de description xs:integer [0-9]{6}|[0-9]{12}');
$table->date('date_de_ponte')
->comment('Le date de ponte xs:date');
$table->date('dcr')
->comment('Date dcr ? xs:date');
});
} else {
DB::statement(
'ALTER TABLE `traca_oeufs` CHANGE COLUMN `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;'
);
// ! Sanitize column data code boite
DB::table('traca_oeufs')
->where('code_boite', 'not regexp', '^[0-9]+$')->get()
->map(function (object $line) {
DB::table('traca_oeufs')
->where('id', '=', $line->id)
->update(['code_boite' => intval($line->code_boite)]);
});
Schema::table('traca_oeufs', function (Blueprint $table) {
$table->renameColumn('ean13', 'ean_13');
$table->renameColumn('date_ponte', 'date_de_ponte');
});
Schema::table('traca_oeufs', function (Blueprint $table) {
$table->dropColumn(['date_emballage']);
$table->unsignedBigInteger('code_boite')
->index()
->comment('Le code de la boite d\'oeufs xs:integer [0-9]{9}|[0-9]{10}')
->change();
$table->string('code_ede', 10)
->comment('Le code EDE xs:string length 8')
->change();
$table->string('code_produit', 14)
->comment('Le code produit xs:string [0-9]{8}.[0-9]{3}')
->change();
$table->string('libelle_produit', 38)
->comment('Le libellé du produit xs:string length 35')
->change();
$table->unsignedBigInteger('lot_externe')
->index()
->comment('Pas de description xs:integer [0-9]{6}|[0-9]{12}')
->change();
$table->unsignedBigInteger('ean_13')
->index()
->comment('Code ean 13 xs:integer [0-9]{13}')
->change();
$table->date('dcr')
->comment('Date dcr ? xs:date')
->change();
});
} //end if
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('traca_oeufs');
}
}

View file

@ -0,0 +1,73 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateTracaVolaillesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('traca_volailles', function (Blueprint $table) {
$table->id();
$table->string('code_art', 14)
->comment('Code article xs:string [0-9]{8}(\.[0-9]{3})?');
$table->string('article', 38)
->comment('Libellé article xs:string length 35');
$table->string('lot_code_externe', 12)
->comment('Lot de provenance xs:string length 10');
$table->string('code_eleveur', 13)
->comment('Code éleveur xs:string length 11');
$table->unsignedSmallInteger('num_commande')
->index()
->comment('Numéro de commande xs:int [0-9]{6}');
$table->unsignedMediumInteger('lot_opa')->nullable()
->index()
->comment('Lot OPA xs:string [*]{0}|[0-9][0-9]{5} (soit chaine vide, soit integer)');
$table->unsignedInteger('gencod_prix')->nullable()
->index()
->comment('Gencode prix xs:string [*]{0}|[0-9]{7} (soit chaine vide, soit integer)');
$table->unsignedInteger('gencod_poids')->nullable()
->index()
->comment('Gencode poids xs:string [*]{0}|[0-9]{7} (soit chaine vide, soit integer)');
$table->unsignedBigInteger('lot_abattoir')
->index()
->comment('Numéro de lot de l\'abattoir xs:int [0-9]{9}');
$table->unsignedBigInteger('client_commande')
->index()
->comment('Client numéro de commande');
$table->string('enseigne', 34)
->comment('Nom enseigne');
$table->string('marque', 34)
->comment('Nom marque');
$table->string('famille', 34)
->comment('Nom famille');
$table->date('date_expe')
->comment('Date d\'expédition xs:date');
$table->date('date_de_prep')
->comment('Date de préparation xs:date');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('traca_volailles');
}
}

View file

@ -0,0 +1,62 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreateVisuelLibellesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasTable('visuels_libelles')) {
Schema::rename('visuels_libelles', 'visuel_libelles');
}
if (!Schema::hasTable('visuel_libelles')) {
Schema::create('visuel_libelles', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('ean_13')
->index()
->comment('Code ean 13');
$table->string('libelle')
->comment('Libellé');
$table->string('path')
->comment('Chemin relatif vers l\'image.');
});
} else {
DB::statement(
'ALTER TABLE `visuel_libelles` CHANGE COLUMN `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;'
);
Schema::table('visuel_libelles', function (Blueprint $table) {
$table->renameColumn('ean13', 'ean_13');
});
Schema::table('visuel_libelles', function (Blueprint $table) {
$table->unsignedBigInteger('ean_13')
->index()
->comment('Code ean 13')
->change();
$table->string('libelle')
->comment('Libellé')
->change();
$table->string('path')
->comment('Chemin relatif vers l\'image.')
->change();
});
} //end if
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('visuel_libelles');
}
}

View file

@ -0,0 +1,82 @@
<?php
use App\Models\Eleveur;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class CreateMiseEnPlacesTable extends Migration
{
/**
* Run the migrations.
*
* TODO: rework columns when implementing cafel API.
*
* @return void
*/
public function up()
{
if (!Schema::hasTable('mise_en_place')) {
Schema::create('mise_en_places', function (Blueprint $table) {
$table->id();
$table->string('code_lot_pondeuse', 50)
->nullable();
$table->unsignedTinyInteger('hectares_parcours_pondeuse')
->nullable();
$table->unsignedTinyInteger('presence_ruche_pondeuse')
->nullable();
$table->unsignedTinyInteger('zone_mellifere_pondeuse')
->nullable();
$table->string('nom_couvoir')->nullable();
$table->string('ville_couvoir')->nullable();
$table->string('cp_couvoir')->nullable();
$table->string('raison_sociale_eleveur_poulettes')->nullable();
$table->string('code_inuav_poulettes')->nullable();
$table->string('nom_eleveur_poulettes')->nullable();
$table->string('prenom_eleveur_poulettes')->nullable();
$table->string('ville_eleveur_poulettes')->nullable();
$table->string('cp_eleveur_poulettes')->nullable();
$table->date('date_naissance_poulettes')->nullable();
$table->date('date_transfert_poulettes')->nullable();
$table->foreignIdFor(Eleveur::class)
->comment('Clé étrangère éleveur id');
});
} else {
Schema::rename('mise_en_place', 'mise_en_places');
DB::statement(
'ALTER TABLE `mise_en_places` CHANGE COLUMN `eleveurId_pondeuse` `eleveur_id` BIGINT(20);'
);
DB::statement(
// phpcs:ignore Generic.Files.LineLength.TooLong
'ALTER TABLE `mise_en_places` CHANGE COLUMN `id` `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT FIRST;'
);
Schema::table('mise_en_places', function (Blueprint $table) {
$table->unsignedBigInteger('id')->unsigned()->change();
});
Schema::table('mise_en_places', function (Blueprint $table) {
$table->foreignId('eleveur_id')
->comment('Clé étrangère éleveur id')->change();
});
Schema::table('mise_en_places', function (Blueprint $table) {
$table->foreign('eleveur_id')
->references('id')
->on('eleveurs');
});
} //end if
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('mise_en_places');
}
}