<?php

use Phinx\Db\Adapter\MysqlAdapter;

class CreatePropietario extends Phinx\Migration\AbstractMigration
{
	public function change(): void
	{
		$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
		$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
		$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");

		$this->table('propietario', ['id' => '`rut`'])
			->addColumn('rut', 'integer', ['length' => 10, 'null' => false, 'signed' => false])
			->addColumn('dv', 'char', ['length' => 1, 'null' => false])
			->addColumn('nombres', 'string', ['length' => 255, 'null' => false])
			->addColumn('apellido_paterno', 'string', ['length' => 50, 'null' => false])
			->addColumn('apellido_materno', 'string', ['length' => 50, 'null' => false])
			->addColumn('sexo', 'string', ['length' => 1, 'default' => null, 'null' => true])
			->addColumn('estado_civil', 'string', ['length' => 50, 'default' => null, 'null' => true])
			->addColumn('profesion', 'string', ['length' => 100, 'default' => null, 'null' => true])
			->addColumn('direccion', 'integer', ['length' => 10, 'default' => 0, 'null' => false, 'signed' => false])
			->addColumn('telefono', 'integer', ['length' => 10, 'default' => 0, 'signed' => false])
			->addColumn('email', 'string', ['length' => 100, 'default' => null, 'null' => true])
			->addColumn('representante', 'integer', ['length' => 10, 'default' => 0])
			->addColumn('otro', 'integer', ['length' => 11, 'default' => 0])
			->create();
		$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
	}
}
