<?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('supplier_host_servers', function(Blueprint $table)
		{
			$table->id();
			$table->timestamps();
			$table->integer('site_id')->unsigned();
			$table->boolean('active')->default(false);

			$table->boolean('debug')->nullable();
			$table->string('name',128);
			$table->string('notes')->nullable();
			$table->string('provision_plugin', 128)->nullable();
			$table->text('provision_plugin_data')->nullable();
			$table->integer('max_accounts')->nullable();
			$table->string('whitelabel_url', 256)->nullable();
			$table->string('manage_url', 256)->nullable();
			$table->string('manage_username', 45)->nullable();
			$table->string('manage_password', 45)->nullable();

			$table->foreign(['site_id'])->references(['id'])->on('sites');

			$table->integer('supplier_id')->unsigned()->nullable();
			$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');

			$table->unique(['id','site_id']);
		});
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('supplier_host_servers');
	}
};