71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
|
<?php
|
||
|
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
||
|
return new class extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function up()
|
||
|
{
|
||
|
Schema::create('invoice__provider', function (Blueprint $table) {
|
||
|
$table->timestamps();
|
||
|
$table->integer('invoice_id')->unsigned();
|
||
|
$table->integer('provider_oauth_id')->unsigned();
|
||
|
$table->integer('site_id')->unsigned();
|
||
|
$table->string('ref');
|
||
|
$table->integer('synctoken');
|
||
|
|
||
|
$table->foreign(['invoice_id','site_id'])->references(['id','site_id'])->on('invoices');
|
||
|
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
|
||
|
});
|
||
|
|
||
|
Schema::create('product__provider', function (Blueprint $table) {
|
||
|
$table->integer('product_id')->unsigned();
|
||
|
$table->integer('provider_oauth_id')->unsigned();
|
||
|
$table->integer('site_id')->unsigned();
|
||
|
$table->string('ref');
|
||
|
|
||
|
$table->foreign(['product_id','site_id'])->references(['id','site_id'])->on('products');
|
||
|
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
|
||
|
});
|
||
|
|
||
|
Schema::create('tax__provider', function (Blueprint $table) {
|
||
|
$table->timestamps();
|
||
|
$table->integer('tax_id')->unsigned();
|
||
|
$table->integer('provider_oauth_id')->unsigned();
|
||
|
$table->integer('site_id')->unsigned();
|
||
|
$table->string('ref');
|
||
|
$table->integer('synctoken');
|
||
|
|
||
|
$table->foreign(['tax_id'])->references(['id'])->on('taxes');
|
||
|
$table->foreign(['provider_oauth_id','site_id'])->references(['id','site_id'])->on('provider_oauth');
|
||
|
});
|
||
|
|
||
|
Schema::table('products', function (Blueprint $table) {
|
||
|
$table->dropColumn('accounting');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function down()
|
||
|
{
|
||
|
Schema::dropIfExists('tax__provider');
|
||
|
Schema::dropIfExists('product__provider');
|
||
|
Schema::dropIfExists('invoice__provider');
|
||
|
|
||
|
Schema::table('products', function (Blueprint $table) {
|
||
|
$table->string('accounting');
|
||
|
});
|
||
|
}
|
||
|
};
|