diff --git a/app/composer.json b/app/composer.json index 1223dfc..00f4029 100644 --- a/app/composer.json +++ b/app/composer.json @@ -17,7 +17,8 @@ "phpoffice/phpspreadsheet": "^3", "predis/predis": "^2", "robmorgan/phinx": "^0.16", - "slim/slim": "^4" + "slim/slim": "^4", + "symfony/string": "^7.2" }, "require-dev": { "fakerphp/faker": "^1", diff --git a/app/generate-migrations.php b/app/generate-migrations.php new file mode 100644 index 0000000..9c1c095 --- /dev/null +++ b/app/generate-migrations.php @@ -0,0 +1,730 @@ +tables)) { + $results = $this->connection->query("SHOW TABLES"); + $rows = $results->fetchAll(PDO::FETCH_ASSOC); + $this->tables = array_map(function($row) { + return $row["Tables_in_{$this->database}"]; + }, $rows); + } + return $this->tables; + } + public function getTableDefinition(string $table): string + { + if (!isset($this->definitions[$table])) { + $results = $this->connection->query("SHOW CREATE TABLE {$table}"); + $row = $results->fetch(PDO::FETCH_ASSOC); + $this->definitions[$table] = $row['Create Table']; + } + return $this->definitions[$table]; + } + public function parseTableDefinition(string $table, int $offset = 2): string + { + $this->extractLines($table); + $tableLine = "\$this->table('{$table}'"; + if (count($this->primary) === 1) { + $tableLine .= ", ['id' => '{$this->primary[0]}']"; + } elseif (count($this->primary) > 1) { + $primaryString = implode(', ', array_map(function($key) {return "'{$key}'";}, $this->primary)); + $tableLine .= ", ['id' = false, 'primary_key' => [{$primaryString}]]"; + } + $tableLine .= ')'; + $output = [$this->prefixLine($tableLine, $offset)]; + foreach ($this->columns as $column) { + $output []= $this->prefixLine($column, $offset + 1); + } + foreach ($this->constraints as $constraint) { + $output []= $this->prefixLine($constraint, $offset + 1); + } + $output []= $this->prefixLine('->create();', $offset + 1); + return implode(PHP_EOL, $output); + } + public function getTableIndex(string $table): int + { + return array_search($table, $this->getTables()); + } + + protected array $tables; + protected array $definitions; + protected array $primary; + protected array $columns; + protected array $constraints; + + protected function extractLines(string $table): void + { + $this->primary = []; + $this->columns = []; + $this->constraints = []; + $lines = explode(PHP_EOL, $this->definitions[$table]); + + array_shift($lines); + foreach ($lines as $line) { + if (str_starts_with(trim($line), ') ENGINE')) { + break; + } + if (str_starts_with(trim($line), '`id`') or str_starts_with(trim($line), 'KEY')) { + continue; + } + if (str_starts_with(trim($line), 'PRIMARY KEY')) { + if (!str_contains($line, '`id`')) { + $ini = strpos($line, '(') + 1; + $end = strpos($line, ')', $ini); + $this->primary []= substr($line, $ini, $end - $ini); + } + continue; + } + if (str_starts_with(trim($line), 'CONSTRAINT')) { + $this->constraints []= (new ConstraintParser($line))->parse(); + continue; + } + $this->columns []= (new ColumnParser($line))->parse(); + } + } + protected function prefixLine(string $line, int $length, string $character = "\t"): string + { + if ($length === 0) { + return $line; + } + return implode('', array_fill(0, $length, $character)) . $line; + } +} +class DataRepository +{ + public function __construct(protected Incoviba\Common\Define\Connection $connection) {} + + public int $size; + + public function getData(string $table): Generator + { + $query = $this->connection->getQueryBuilder() + ->select() + ->from($table); + $results = $this->connection->query($query); + $this->size = $results->rowCount(); + while ($row = $results->fetch(PDO::FETCH_ASSOC)) { + yield $row; + } + } +} +class ColumnParser +{ + public function __construct(protected string $line) {} + + public function parse(): string + { + return "->addColumn('{$this->getName()}', '{$this->getType()}'{$this->getOptions()})"; + } + + protected int $ini; + protected int $end; + protected array $parts; + protected array $options; + + protected function getName(): string + { + $ini = $this->getIni(); + $end = $this->getEnd(); + return substr($this->line, $ini, $end - $ini); + } + protected function getType(): string + { + $parts = $this->getParts(); + $type = array_shift($parts); + + if (str_contains($type, '(')) { + list($type, $length) = explode('(', $type); + $this->options []= "'length' => " . rtrim($length, ')'); + } + return match($type) { + 'int' => 'integer', + 'tinyint' => 'boolean', + 'varchar' => 'string', + default => $type + }; + } + protected function getOptions(): string + { + $parts = $this->getParts(); + array_shift($parts); + $validOptions = [ + 'default' => function($parts) { + $i = array_search('default', array_map(function($part) {return strtolower($part);}, $parts)); + return ['default', $parts[$i + 1]]; + }, + 'null' => function($parts) { + $value = true; + $i = array_search('null', array_map(function($part) {return strtolower($part);}, $parts)); + if (key_exists($i - 1, $parts) and strtolower($parts[$i - 1]) === 'not') { + $value = false; + } + return ['null', $value]; + }, + 'unsigned' => function($parts) { + return ['signed', false]; + }, + 'auto_increment' => function($parts) { + return ['auto_increment', true]; + } + ]; + foreach ($validOptions as $validOption => $callable) { + if (str_contains(strtolower($this->line), $validOption)) { + list($option, $value) = $callable($parts); + if (strtolower($value) === 'null') { + $value = 'null'; + } + if ($value !== 'null' and !is_bool($value) and !ctype_digit($value)) { + $value = trim($value, "'"); + $value = "'{$value}'"; + } + if (is_bool($value)) { + $value = $value ? 'true' : 'false'; + } + $this->options []= "'{$option}' => {$value}"; + } + } + if (count($this->options) === 0) { + return ''; + } + return ', [' . implode(', ', $this->options) . ']'; + } + protected function getIni(): int + { + if (!isset($this->ini)) { + $this->ini = strpos($this->line, '`') + 1; + } + return $this->ini; + } + protected function getEnd(): int + { + if (!isset($this->end)) { + $this->end = strpos($this->line, '`', $this->getIni()); + } + return $this->end; + } + protected function getParts(): array + { + if (!isset($this->parts)) { + $this->parts = explode(' ', trim(substr($this->line, $this->getEnd() + 1), ' ,')); + } + return $this->parts; + } +} +class ConstraintParser +{ + public function __construct(protected string $line) {} + + public function parse(): string + { + return "->addForeignKey({$this->getColumns()}, '{$this->getTable()}', {$this->getReferences()}, ['delete' => 'cascade', 'update' => 'cascade'])"; + } + + protected function getColumns(): string + { + $ini = strpos(strtolower($this->line), 'foreign key') + strlen('FOREIGN KEY '); + $ini = strpos($this->line, '(', $ini) + 1; + $end = strpos(strtolower($this->line), ' references', $ini + 1) - strlen(')'); + return $this->getNames($ini, $end); + } + protected function getTable(): string + { + $ini = strpos(strtolower($this->line), 'references') + strlen('REFERENCES ') + 1; + $end = strpos($this->line, '`', $ini + 1); + return substr($this->line, $ini, $end - $ini); + } + protected function getReferences(): string + { + $ini = strpos($this->line, '(', strpos(strtolower($this->line), 'references')) + 1; + $end = strpos($this->line, ')', $ini); + return $this->getNames($ini, $end); + } + protected function getNames($ini, $end): string + { + $names = substr($this->line, $ini, $end - $ini); + if (!str_contains($names, ',')) { + return str_replace('`', "'", $names); + } + $names = explode(', ', $names); + $columns = array_map(function($name) {return str_replace('`', "'", $name);}, $names); + return '[' . implode(', ', $columns) . ']'; + } +} +class MigrationGenerator +{ + public function __construct(protected Config $settings) + { + $this->databaseName = $settings->getEnv('DB_DATABASE'); + $this->migrationsPath = $settings->getMigrationsPath(); + $this->startDate = $settings->getStartDate(); + $this->database = new Incoviba\Common\Implement\Database\MySQL($settings->getEnv('DB_HOST'), $settings->getEnv('DB_DATABASE'), $settings->getEnv('DB_USER'), $settings->getEnv('DB_PASSWORD')); + $this->connection = new Incoviba\Common\Implement\Connection($this->database, new Incoviba\Common\Implement\Database\Query\Builder()); + $this->tableRepository = new TableRepository($this->connection, $this->databaseName); + $this->logger = $settings->getLogger(); + } + + public function run(bool $execute = true): void + { + $this->logger->output('Running generate migrations' . (($execute) ? '' : ' [dry-run]'), 250); + foreach ($this->tableRepository->getTables() as $tableName) { + if (in_array($tableName, $this->settings->getSkip())) { + continue; + } + $this->logger->output("Table: {$tableName}"); + $filename = $this->buildFilename($tableName); + if ($execute) { + $this->logger->debug("Filename: {$filename}"); + } else { + $this->logger->output("Filename: {$filename}"); + } + $content = $this->buildFile($tableName); + $this->logger->debug("Content: {$content}"); + + if ($execute) { + $status = file_put_contents($filename, $content); + $this->logger->debug("Saved: " . var_export($status, true)); + try { + $this->registerMigration($tableName); + } catch (PDOException $exception) { + $this->logger->warning($exception); + } + } + } + $this->logger->output("Total tables migrated: " . count($this->tableRepository->getTables()), 250); + } + + protected Incoviba\Common\Define\Database $database; + protected Incoviba\Common\Define\Connection $connection; + protected string $databaseName; + protected string $migrationsPath; + protected DateTimeInterface $startDate; + protected TableRepository $tableRepository; + protected Logger $logger; + + protected function buildFilename(string $table): string + { + $i = $this->tableRepository->getTableIndex($table); + $time = $this->startDate->add(new DateInterval("PT{$i}S")); + return implode(DIRECTORY_SEPARATOR, [ + $this->migrationsPath, + "{$time->format('YmdHis')}_create_{$table}.php" + ]); + } + protected function buildClassName(string $table): string + { + return 'Create' . str_replace(' ', '', ucwords(str_replace('_', ' ', $table))); + } + protected function buildHeader(): string + { + return "buildClassName($table)} extends Phinx\Migration\AbstractMigration"; + } + protected function buildFunction(string $table): string + { + $output = ["{", "\tpublic function change(): void", "\t{"]; + $output []= $this->buildInitialSetup(); + $this->tableRepository->getTableDefinition($table); + $output []= $this->tableRepository->parseTableDefinition($table); + $output []= $this->buildFinalSetup(); + $output []= "\t}"; + return implode(PHP_EOL, $output); + } + protected function buildInitialSetup(): string + { + return implode(PHP_EOL, [ + "\t\t\$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');", + "\t\t\$this->execute(\"ALTER DATABASE CHARACTER SET 'utf8mb4';\");", + "\t\t\$this->execute(\"ALTER DATABASE COLLATE='utf8mb4_general_ci';\");", + '' + ]); + } + protected function buildFinalSetup(): string + { + return "\t\t\$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');"; + } + protected function buildFile(string $table): string + { + return implode(PHP_EOL, [ + $this->buildHeader(), + $this->buildClass($table), + $this->buildFunction($table), + '}', + '' + ]); + } + protected function registerMigration(string $table): void + { + $i = $this->tableRepository->getTableIndex($table); + $time = $this->startDate->add(new DateInterval("PT{$i}S")); + $this->logger->output("Registering migration: {$time->format('Y-m-d H:i:s')}"); + $migrationName = $this->buildClassName($table); + + $query = $this->connection->getQueryBuilder() + ->insert() + ->into('phinxlog') + ->columns(['version', 'migration_name', 'start_time', 'end_time', 'breakpoint']) + ->values(['?', '?', '?', '?', 0]); + + $this->connection->execute($query, [ + $time->format('YmdHis'), + $migrationName, + $time->format('Y-m-d H:i:s'), + $time->format('Y-m-d H:i:s') + ]); + } +} +class SeedGenerator +{ + public function __construct(protected Config $settings) + { + $this->databaseName = $settings->getEnv('DB_DATABASE'); + $this->seedsPath = $settings->getSeedsPath(); + $this->startDate = $settings->getStartDate(); + $this->database = new Incoviba\Common\Implement\Database\MySQL($settings->getEnv('DB_HOST'), $settings->getEnv('DB_DATABASE'), $settings->getEnv('DB_USER'), $settings->getEnv('DB_PASSWORD')); + $this->connection = new Incoviba\Common\Implement\Connection($this->database, new Incoviba\Common\Implement\Database\Query\Builder()); + $this->tableRepository = new TableRepository($this->connection, $this->databaseName); + $this->dataRepository = new DataRepository($this->connection); + $this->logger = $settings->getLogger(); + } + + public function run(bool $execute = true): void + { + $this->logger->output('Running generate seeds' . (($execute) ? '' : ' [dry-run]'), 250); + $tables = $this->tableRepository->getTables(); + foreach ($tables as $table) { + if (in_array($table, $this->settings->getSkip())) { + continue; + } + $this->logger->output("Table: {$table}"); + $filename = $this->buildFilename($table); + if ($execute) { + $this->logger->debug("Filename: {$filename}"); + } else { + $this->logger->output("Filename: {$filename}"); + } + $content = $this->buildFile($table); + $this->logger->debug("Content: {$content}"); + + if ($execute) { + $status = file_put_contents($filename, $content); + $this->logger->debug("Saved: " . var_export($status, true)); + } + } + $this->logger->output("Total tables seeded: " . count($this->tableRepository->getTables()), 250); + } + + protected Incoviba\Common\Define\Database $database; + protected Incoviba\Common\Define\Connection $connection; + protected string $databaseName; + protected string $seedsPath; + protected DateTimeInterface $startDate; + protected TableRepository $tableRepository; + protected DataRepository $dataRepository; + protected Logger $logger; + + protected function buildFilename(string $table): string + { + $i = $this->tableRepository->getTableIndex($table); + $time = $this->startDate->add(new DateInterval("PT{$i}S")); + return implode(DIRECTORY_SEPARATOR, [ + $this->seedsPath, + "{$time->format('YmdHis')}_{$table}_seeder.php" + ]); + } + protected function buildFile(string $table): string + { + return implode(PHP_EOL, [ + $this->buildHeader(), + $this->buildClass($table), + "{", + $this->buildFunction($table), + '}', + '' + ]); + } + protected function buildHeader(): string + { + return "buildClassName($table)} extends AbstractSeed"; + } + protected function buildClassName(string $table): string + { + return str_replace(' ', '', ucwords(str_replace('_', ' ', $table))) . 'Seeder'; + } + protected function buildFunction(string $table): string + { + return implode(PHP_EOL, [ + "\tpublic function run(): void", + "\t{", + $this->buildData($table), + "", + $this->buildInitialSetup(), + "\t\t\$this->table('{$table}')", + "\t\t\t->insert(\$data)", + "\t\t\t->saveData();", + $this->buildFinalSetup(), + "\t}" + ]); + } + protected function buildData(string $table): string + { + $output = ["\t\t\$data = ["]; + $dataGenerator = $this->dataRepository->getData($table); + foreach ($dataGenerator as $row) { + $output []= "\t\t\t["; + foreach ($row as $key => $value) { + if (is_bool($value)) { + $value = $value ? 1 : 0; + } + if (!ctype_digit("{$value}") and $value !== null) { + if (str_contains($value, "'")) { + $value = str_replace("'", "\'", $value); + } + $value = "'{$value}'"; + } + if ($value === null) { + $value = 'null'; + } + if (strlen($value) > 2 and str_starts_with($value, '0')) { + $value = "'{$value}'"; + } + $output []= "\t\t\t\t'{$key}' => {$value},"; + } + $output []= "\t\t\t],"; + } + $output []= "\t\t];"; + $this->logger->debug("Total data: {$this->dataRepository->size}"); + return implode(PHP_EOL, $output); + } + protected function buildInitialSetup(): string + { + return "\t\t\$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');"; + } + protected function buildFinalSetup(): string + { + return "\t\t\$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');"; + } +} + +class Logger +{ + public function __construct(protected bool $verbose = false, protected $quiet = false) {} + + protected array $loggers; + + public function registerLog(Psr\Log\LoggerInterface $logger): Logger + { + $this->loggers['log'] = $logger; + return $this; + } + public function registerOutput(Psr\Log\LoggerInterface $logger): Logger + { + $this->loggers['output'] = $logger; + return $this; + } + public function log(string $message, int $level = 200): void + { + if ($this->canLogLevel($level)) { + $this->loggers['log']->log($level, $message); + } + } + public function output(string $message, int $level = 200): void + { + if ($this->canLogLevel($level)) { + $this->loggers['output']->log($level, $message); + $this->log($message, $level); + } + } + public function __call(string $name, array $arguments) + { + if (method_exists($this->loggers['log'], $name)) { + $levelMap = [ + 'debug' => 100, + 'info' => 200, + 'notice' => 250, + 'warning' => 300, + 'error' => 400, + 'critical' => 500, + 'alert' => 550, + 'emergency' => 600 + ]; + $level = $levelMap[strtolower($name)]; + $this->log($arguments[0], $level); + } + } + + protected function canLogLevel(int $level): bool + { + $minQuiet = 300; + $maxVerbose = 250; + + if ($this->quiet) { + return $level >= $minQuiet; + } + if ($this->verbose) { + return true; + } + return $level >= $maxVerbose; + } +} +class Config +{ + public function __construct() + { + $this->opts = getopt('d:m:s:r:vq', ['date:', 'migrations:', 'seeds:', 'run:', 'verbose', 'quiet']); + } + + public function getStartDate(): DateTimeInterface + { + $dateString = '20141101080000'; + if (isset($this->opts['d']) or isset($this->opts['date'])) { + $dateString = $this->opts['d'] ?? $this->opts['date']; + } + return new DateTimeImmutable($dateString); + } + public function getMigrationsPath(): string + { + $migrationsPath = implode(DIRECTORY_SEPARATOR, [__DIR__, 'resources', 'database', 'migrations']); + if (isset($this->opts['m']) or isset($this->opts['migrations'])) { + $migrationsPath = $this->opts['m'] ?? $this->opts['migrations']; + } + return $migrationsPath; + } + public function getSeedsPath(): string + { + $seedsPath = implode(DIRECTORY_SEPARATOR, [__DIR__, 'resources', 'database', 'seeds']); + if (isset($this->opts['s']) or isset($this->opts['seeds'])) { + $seedsPath = $this->opts['s'] ?? $this->opts['seeds']; + } + return $seedsPath; + } + public function getRun(): int + { + $option = 0; + if (isset($this->opts['r']) or isset($this->opts['run'])) { + $option = $this->opts['r'] ?? $this->opts['run']; + } + if (ctype_digit("{$option}")) { + return (int) $option; + } + return match($option) { + 'm', 'migrations' => 1, + 's', 'seeds' => 2, + 'a', 'all' => 3, + default => 0 + }; + } + public function getEnv(string $name): mixed + { + return $_ENV[$name]; + } + public function getLogger(): Logger + { + return (new Logger($this->isVerbose(), $this->isQuiet())) + ->registerLog($this->getPsrLogger()) + ->registerOutput(new Monolog\Logger('output', [ + new Monolog\Handler\FilterHandler( + (new Monolog\Handler\StreamHandler(STDOUT)) + ->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, true)), + Monolog\Level::Info, + Monolog\Level::Notice + ) + ], [ + new Monolog\Processor\ProcessIdProcessor(), + new Monolog\Processor\MemoryUsageProcessor(), + new Monolog\Processor\MemoryPeakUsageProcessor(), + new Monolog\Processor\PsrLogMessageProcessor() + ])); + } + public function getPsrLogger(): Psr\Log\LoggerInterface + { + return new Monolog\Logger('migrations', + [ + (new Monolog\Handler\RotatingFileHandler('/logs/migrations.log')) + ->setFormatter(new Monolog\Formatter\LineFormatter(null, null, false, false, true)), + ], [ + new Monolog\Processor\ProcessIdProcessor(), + new Monolog\Processor\MemoryUsageProcessor(), + new Monolog\Processor\MemoryPeakUsageProcessor(), + new Monolog\Processor\PsrLogMessageProcessor() + ] + ); + } + public function setSkip(string|array $skip): Config + { + if (is_string($skip)) { + $skip = [$skip]; + } + $this->skip = [...$this->skip ?? [], ...$skip]; + return $this; + } + public function getSkip(): array + { + return $this->skip; + } + public function isVerbose(): bool + { + return isset($this->opts['v']) or isset($this->opts['verbose']); + } + public function isQuiet(): bool + { + return isset($this->opts['q']) or isset($this->opts['quiet']); + } + + protected array $opts; + protected array $skip; +} + +$config = new Config(); +$config->setSkip([ + 'monolog', + 'phinxlog', + 'personas', + 'datos_personas', + 'proveedores', + 'datos_proveedores' +]); + +Monolog\ErrorHandler::register($config->getPsrLogger()); +try { + $generator = new MigrationGenerator($config); + $seeder = new SeedGenerator($config); + + switch ($config->getRun()) { + case 0: + $generator->run(false); + $seeder->run(false); + break; + case 3: + $generator->run(); + $seeder->run(); + break; + case 1: + $generator->run(); + break; + case 2: + $seeder->run(); + break; + } +} catch (Exception $exception) { + $config->getLogger()->warning($exception); +} catch (Error $error) { + $config->getLogger()->error($error); +} diff --git a/app/resources/database/migrations/20141101080000_create_action.php b/app/resources/database/migrations/20141101080000_create_action.php new file mode 100644 index 0000000..59a1cb4 --- /dev/null +++ b/app/resources/database/migrations/20141101080000_create_action.php @@ -0,0 +1,18 @@ +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('action') + ->addColumn('description', 'string', ['length' => 50, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080001_create_agente.php b/app/resources/database/migrations/20141101080001_create_agente.php new file mode 100644 index 0000000..2479113 --- /dev/null +++ b/app/resources/database/migrations/20141101080001_create_agente.php @@ -0,0 +1,26 @@ +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('agente') + ->addColumn('tipo', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('rut', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('descripcion', 'string', ['length' => 100, 'default' => null, 'null' => true]) + ->addColumn('representante', 'string', ['length' => 100, 'default' => null, 'null' => true]) + ->addColumn('telefono', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('correo', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('direccion', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('giro', 'mediumtext', ['default' => null, 'null' => true]) + ->addColumn('abreviacion', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080002_create_agente_tipo.php b/app/resources/database/migrations/20141101080002_create_agente_tipo.php new file mode 100644 index 0000000..6b062da --- /dev/null +++ b/app/resources/database/migrations/20141101080002_create_agente_tipo.php @@ -0,0 +1,21 @@ +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('agente_tipo') + ->addColumn('agente', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('tipo', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('agente', 'agente', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('tipo', 'tipo_agente', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080003_create_avance_construccion.php b/app/resources/database/migrations/20141101080003_create_avance_construccion.php new file mode 100644 index 0000000..9aa96e2 --- /dev/null +++ b/app/resources/database/migrations/20141101080003_create_avance_construccion.php @@ -0,0 +1,26 @@ +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('avance_construccion') + ->addColumn('proyecto', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('numero', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('avance', 'double', ['null' => false, 'signed' => false]) + ->addColumn('estado_pago', 'double', ['null' => false, 'signed' => false]) + ->addColumn('pagado', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('uf', 'double', ['default' => null, 'null' => true, 'signed' => false]) + ->addColumn('fecha_pagado', 'date', ['default' => null, 'null' => true]) + ->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080004_create_backup.php b/app/resources/database/migrations/20141101080004_create_backup.php new file mode 100644 index 0000000..a9c97f4 --- /dev/null +++ b/app/resources/database/migrations/20141101080004_create_backup.php @@ -0,0 +1,18 @@ +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('backup') + ->addColumn('date', 'datetime', ['default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080005_create_banco.php b/app/resources/database/migrations/20141101080005_create_banco.php new file mode 100644 index 0000000..c497f80 --- /dev/null +++ b/app/resources/database/migrations/20141101080005_create_banco.php @@ -0,0 +1,18 @@ +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('banco') + ->addColumn('nombre', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080006_create_bono_pie.php b/app/resources/database/migrations/20141101080006_create_bono_pie.php new file mode 100644 index 0000000..0df1c6d --- /dev/null +++ b/app/resources/database/migrations/20141101080006_create_bono_pie.php @@ -0,0 +1,20 @@ +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('bono_pie') + ->addColumn('valor', 'float', ['default' => null, 'null' => true]) + ->addColumn('pago', 'integer', ['length' => 11, 'default' => null, 'null' => true, 'signed' => false]) + ->addForeignKey('pago', 'pago', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080007_create_cartolas.php b/app/resources/database/migrations/20141101080007_create_cartolas.php new file mode 100644 index 0000000..325be8f --- /dev/null +++ b/app/resources/database/migrations/20141101080007_create_cartolas.php @@ -0,0 +1,23 @@ +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('cartolas') + ->addColumn('cuenta_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('cargos', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('abonos', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('saldo', 'bigint', ['length' => 20, 'default' => 0, 'null' => false]) + ->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080008_create_categorias_centros_costos.php b/app/resources/database/migrations/20141101080008_create_categorias_centros_costos.php new file mode 100644 index 0000000..5685276 --- /dev/null +++ b/app/resources/database/migrations/20141101080008_create_categorias_centros_costos.php @@ -0,0 +1,18 @@ +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('categorias_centros_costos') + ->addColumn('descripcion', 'string', ['length' => 255, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080009_create_centros_costos.php b/app/resources/database/migrations/20141101080009_create_centros_costos.php new file mode 100644 index 0000000..0a302ac --- /dev/null +++ b/app/resources/database/migrations/20141101080009_create_centros_costos.php @@ -0,0 +1,24 @@ +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('centros_costos') + ->addColumn('tipo_centro_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('categoria_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('tipo_cuenta_id', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('cuenta_contable', 'string', ['length' => 100, 'null' => false]) + ->addColumn('descripcion', 'mediumtext', ['null' => false]) + ->addForeignKey('tipo_centro_id', 'tipos_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('categoria_id', 'categorias_centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080010_create_cierre.php b/app/resources/database/migrations/20141101080010_create_cierre.php new file mode 100644 index 0000000..f418553 --- /dev/null +++ b/app/resources/database/migrations/20141101080010_create_cierre.php @@ -0,0 +1,23 @@ +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('cierre') + ->addColumn('proyecto', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('precio', 'double', ['null' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('relacionado', 'integer', ['length' => 1, 'default' => 0]) + ->addColumn('propietario', 'integer', ['length' => 10, 'default' => 0, 'signed' => false]) + ->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080011_create_cobro.php b/app/resources/database/migrations/20141101080011_create_cobro.php new file mode 100644 index 0000000..f8acabd --- /dev/null +++ b/app/resources/database/migrations/20141101080011_create_cobro.php @@ -0,0 +1,26 @@ +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('cobro') + ->addColumn('proyecto', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('agente', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('tipo', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('fecha', 'date', ['default' => null, 'null' => true]) + ->addColumn('valor', 'float', ['default' => null, 'null' => true]) + ->addColumn('iva', 'float', ['default' => 0]) + ->addColumn('uf', 'float', ['default' => null, 'null' => true]) + ->addColumn('identificador', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('glosa', 'mediumtext', ['default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080012_create_comentario.php b/app/resources/database/migrations/20141101080012_create_comentario.php new file mode 100644 index 0000000..daa51e0 --- /dev/null +++ b/app/resources/database/migrations/20141101080012_create_comentario.php @@ -0,0 +1,21 @@ +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('comentario') + ->addColumn('venta', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('fecha', 'datetime', ['default' => null, 'null' => true]) + ->addColumn('texto', 'blob', ['default' => null, 'null' => true]) + ->addColumn('estado', 'integer', ['length' => 11, 'default' => 1]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080013_create_comuna.php b/app/resources/database/migrations/20141101080013_create_comuna.php new file mode 100644 index 0000000..764c13d --- /dev/null +++ b/app/resources/database/migrations/20141101080013_create_comuna.php @@ -0,0 +1,20 @@ +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('comuna') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->addColumn('provincia', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('provincia', 'provincia', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080014_create_configurations.php b/app/resources/database/migrations/20141101080014_create_configurations.php new file mode 100644 index 0000000..9bc8705 --- /dev/null +++ b/app/resources/database/migrations/20141101080014_create_configurations.php @@ -0,0 +1,19 @@ +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('configurations') + ->addColumn('name', 'string', ['length' => 30, 'null' => false]) + ->addColumn('value', 'string', ['length' => 255, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080015_create_costo.php b/app/resources/database/migrations/20141101080015_create_costo.php new file mode 100644 index 0000000..034fc43 --- /dev/null +++ b/app/resources/database/migrations/20141101080015_create_costo.php @@ -0,0 +1,20 @@ +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('costo') + ->addColumn('proyecto', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('tipo', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('valor', 'float', ['default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080016_create_credito.php b/app/resources/database/migrations/20141101080016_create_credito.php new file mode 100644 index 0000000..8d1cea0 --- /dev/null +++ b/app/resources/database/migrations/20141101080016_create_credito.php @@ -0,0 +1,24 @@ +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('credito') + ->addColumn('banco', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('valor', 'float', ['default' => null, 'null' => true]) + ->addColumn('fecha', 'date', ['default' => null, 'null' => true]) + ->addColumn('uf', 'float', ['default' => null, 'null' => true]) + ->addColumn('abonado', 'integer', ['length' => 1, 'default' => 0]) + ->addColumn('fecha_abono', 'date', ['default' => null, 'null' => true]) + ->addColumn('pago', 'integer', ['length' => 11, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080017_create_cuenta.php b/app/resources/database/migrations/20141101080017_create_cuenta.php new file mode 100644 index 0000000..f64fb4c --- /dev/null +++ b/app/resources/database/migrations/20141101080017_create_cuenta.php @@ -0,0 +1,22 @@ +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('cuenta') + ->addColumn('inmobiliaria', 'integer', ['length' => 8, 'null' => false, 'signed' => false]) + ->addColumn('banco', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('cuenta', 'string', ['length' => 50, 'null' => false]) + ->addForeignKey('inmobiliaria', 'inmobiliaria', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('banco', 'banco', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080018_create_cuota.php b/app/resources/database/migrations/20141101080018_create_cuota.php new file mode 100644 index 0000000..f1a4b5c --- /dev/null +++ b/app/resources/database/migrations/20141101080018_create_cuota.php @@ -0,0 +1,30 @@ +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('cuota') + ->addColumn('pie', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('valor_$', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('estado', 'boolean', ['length' => 1, 'default' => 0]) + ->addColumn('banco', 'string', ['length' => 20, 'null' => false]) + ->addColumn('fecha_pago', 'date', ['default' => null, 'null' => true]) + ->addColumn('abonado', 'boolean', ['length' => 1, 'default' => 0]) + ->addColumn('fecha_abono', 'date', ['default' => null, 'null' => true]) + ->addColumn('uf', 'double', ['default' => 0]) + ->addColumn('pago', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('numero', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addForeignKey('pago', 'pago', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('pie', 'pie', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080021_create_depositos.php b/app/resources/database/migrations/20141101080021_create_depositos.php new file mode 100644 index 0000000..80c1758 --- /dev/null +++ b/app/resources/database/migrations/20141101080021_create_depositos.php @@ -0,0 +1,23 @@ +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('depositos') + ->addColumn('cuenta_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('capital', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('futuro', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('inicio', 'date', ['null' => false]) + ->addColumn('termino', 'date', ['null' => false]) + ->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080022_create_direccion.php b/app/resources/database/migrations/20141101080022_create_direccion.php new file mode 100644 index 0000000..a48601c --- /dev/null +++ b/app/resources/database/migrations/20141101080022_create_direccion.php @@ -0,0 +1,22 @@ +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('direccion') + ->addColumn('calle', 'string', ['length' => 255, 'null' => false]) + ->addColumn('numero', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('extra', 'string', ['length' => 255, 'null' => false]) + ->addColumn('comuna', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('comuna', 'comuna', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080023_create_entrega.php b/app/resources/database/migrations/20141101080023_create_entrega.php new file mode 100644 index 0000000..7dac05e --- /dev/null +++ b/app/resources/database/migrations/20141101080023_create_entrega.php @@ -0,0 +1,24 @@ +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('entrega') + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('fondo_operacion', 'integer', ['length' => 11, 'default' => 0]) + ->addColumn('fondo_reserva', 'integer', ['length' => 11, 'default' => 0]) + ->addColumn('fecha_fondo_operacion', 'date', ['default' => null, 'null' => true]) + ->addColumn('fecha_fondo_reserva', 'date', ['default' => null, 'null' => true]) + ->addColumn('pago_operacion', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('pago_reserva', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080024_create_escritura.php b/app/resources/database/migrations/20141101080024_create_escritura.php new file mode 100644 index 0000000..5959d1d --- /dev/null +++ b/app/resources/database/migrations/20141101080024_create_escritura.php @@ -0,0 +1,23 @@ +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('escritura') + ->addColumn('valor', 'bigint', ['length' => 20, 'null' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('uf', 'float', ['default' => null, 'null' => true]) + ->addColumn('abonado', 'integer', ['length' => 11, 'default' => 0]) + ->addColumn('fecha_abono', 'date', ['default' => null, 'null' => true]) + ->addColumn('pago', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080025_create_estado_cierre.php b/app/resources/database/migrations/20141101080025_create_estado_cierre.php new file mode 100644 index 0000000..df5343e --- /dev/null +++ b/app/resources/database/migrations/20141101080025_create_estado_cierre.php @@ -0,0 +1,22 @@ +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('estado_cierre') + ->addColumn('cierre', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('tipo', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addForeignKey('cierre', 'cierre', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('tipo', 'tipo_estado_cierre', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080026_create_estado_cobro.php b/app/resources/database/migrations/20141101080026_create_estado_cobro.php new file mode 100644 index 0000000..4f79ebe --- /dev/null +++ b/app/resources/database/migrations/20141101080026_create_estado_cobro.php @@ -0,0 +1,20 @@ +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('estado_cobro') + ->addColumn('cobro', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('estado', 'integer', ['length' => 11, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080027_create_estado_pago.php b/app/resources/database/migrations/20141101080027_create_estado_pago.php new file mode 100644 index 0000000..f9b51ef --- /dev/null +++ b/app/resources/database/migrations/20141101080027_create_estado_pago.php @@ -0,0 +1,21 @@ +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('estado_pago') + ->addColumn('pago', 'integer', ['length' => 11, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('estado', 'integer', ['length' => 11, 'null' => false]) + ->addForeignKey('estado', 'tipo_estado_pago', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080028_create_estado_precio.php b/app/resources/database/migrations/20141101080028_create_estado_precio.php new file mode 100644 index 0000000..811d1bb --- /dev/null +++ b/app/resources/database/migrations/20141101080028_create_estado_precio.php @@ -0,0 +1,22 @@ +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('estado_precio') + ->addColumn('precio', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('estado', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('precio', 'precio', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('estado', 'tipo_estado_precio', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080029_create_estado_problema.php b/app/resources/database/migrations/20141101080029_create_estado_problema.php new file mode 100644 index 0000000..216c296 --- /dev/null +++ b/app/resources/database/migrations/20141101080029_create_estado_problema.php @@ -0,0 +1,20 @@ +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('estado_problema') + ->addColumn('problema', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('fecha', 'date', ['default' => null, 'null' => true]) + ->addColumn('estado', 'enum', ['length' => 'ingreso','revision','correccion','ok', 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080030_create_estado_proyecto.php b/app/resources/database/migrations/20141101080030_create_estado_proyecto.php new file mode 100644 index 0000000..5f35bc5 --- /dev/null +++ b/app/resources/database/migrations/20141101080030_create_estado_proyecto.php @@ -0,0 +1,22 @@ +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('estado_proyecto') + ->addColumn('proyecto', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('estado', 'integer', ['length' => 11, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('estado', 'tipo_estado_proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080031_create_estado_proyecto_agente.php b/app/resources/database/migrations/20141101080031_create_estado_proyecto_agente.php new file mode 100644 index 0000000..0df4382 --- /dev/null +++ b/app/resources/database/migrations/20141101080031_create_estado_proyecto_agente.php @@ -0,0 +1,20 @@ +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('estado_proyecto_agente') + ->addColumn('agente', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('tipo', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080032_create_estado_unidad_bloqueada.php b/app/resources/database/migrations/20141101080032_create_estado_unidad_bloqueada.php new file mode 100644 index 0000000..fca6cc6 --- /dev/null +++ b/app/resources/database/migrations/20141101080032_create_estado_unidad_bloqueada.php @@ -0,0 +1,20 @@ +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('estado_unidad_bloqueada') + ->addColumn('unidad', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('tipo', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080033_create_estado_venta.php b/app/resources/database/migrations/20141101080033_create_estado_venta.php new file mode 100644 index 0000000..7fd7082 --- /dev/null +++ b/app/resources/database/migrations/20141101080033_create_estado_venta.php @@ -0,0 +1,22 @@ +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('estado_venta') + ->addColumn('venta', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('estado', 'integer', ['length' => 11, 'default' => 1, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addForeignKey('estado', 'tipo_estado_venta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('venta', 'venta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080034_create_estados_cuentas.php b/app/resources/database/migrations/20141101080034_create_estados_cuentas.php new file mode 100644 index 0000000..787226f --- /dev/null +++ b/app/resources/database/migrations/20141101080034_create_estados_cuentas.php @@ -0,0 +1,21 @@ +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('estados_cuentas') + ->addColumn('cuenta_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('active', 'boolean', ['length' => 1, 'null' => false]) + ->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080035_create_etapa_proyecto.php b/app/resources/database/migrations/20141101080035_create_etapa_proyecto.php new file mode 100644 index 0000000..439ec34 --- /dev/null +++ b/app/resources/database/migrations/20141101080035_create_etapa_proyecto.php @@ -0,0 +1,19 @@ +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('etapa_proyecto') + ->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('orden', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080036_create_factura_proyecto_operador.php b/app/resources/database/migrations/20141101080036_create_factura_proyecto_operador.php new file mode 100644 index 0000000..7bad240 --- /dev/null +++ b/app/resources/database/migrations/20141101080036_create_factura_proyecto_operador.php @@ -0,0 +1,25 @@ +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('factura_proyecto_operador') + ->addColumn('proyecto_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('operador_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('factura', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('valor_uf', 'double', ['null' => false, 'signed' => false]) + ->addColumn('valor_neto', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('iva', 'integer', ['length' => 10, 'default' => 0, 'signed' => false]) + ->addForeignKey('proyecto_id', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('operador_id', 'agente', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080037_create_factura_venta.php b/app/resources/database/migrations/20141101080037_create_factura_venta.php new file mode 100644 index 0000000..1556250 --- /dev/null +++ b/app/resources/database/migrations/20141101080037_create_factura_venta.php @@ -0,0 +1,22 @@ +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('factura_venta') + ->addColumn('factura_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('venta_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('valor', 'double', ['null' => false]) + ->addForeignKey('factura_id', 'factura_proyecto_operador', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('venta_id', 'venta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080038_create_facturas.php b/app/resources/database/migrations/20141101080038_create_facturas.php new file mode 100644 index 0000000..0cd4c00 --- /dev/null +++ b/app/resources/database/migrations/20141101080038_create_facturas.php @@ -0,0 +1,22 @@ +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('facturas') + ->addColumn('venta_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('index', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('proporcion', 'double', ['null' => false, 'signed' => false]) + ->addColumn('data', 'text', ['null' => false]) + ->addForeignKey('venta_id', 'venta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080039_create_inmobiliaria.php b/app/resources/database/migrations/20141101080039_create_inmobiliaria.php new file mode 100644 index 0000000..e395c8c --- /dev/null +++ b/app/resources/database/migrations/20141101080039_create_inmobiliaria.php @@ -0,0 +1,25 @@ +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('inmobiliaria', ['id' => '`rut`']) + ->addColumn('rut', 'integer', ['length' => 8, 'null' => false, 'signed' => false]) + ->addColumn('dv', 'char', ['length' => 1, 'default' => null, 'null' => true]) + ->addColumn('razon', 'string', ['length' => 255, 'default' => null, 'null' => true]) + ->addColumn('abreviacion', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('cuenta', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('banco', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('sociedad', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('sigla', 'string', ['length' => 4, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080040_create_inmobiliarias_nubox.php b/app/resources/database/migrations/20141101080040_create_inmobiliarias_nubox.php new file mode 100644 index 0000000..e2ff626 --- /dev/null +++ b/app/resources/database/migrations/20141101080040_create_inmobiliarias_nubox.php @@ -0,0 +1,22 @@ +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('inmobiliarias_nubox') + ->addColumn('inmobiliaria_rut', 'integer', ['length' => 8, 'null' => false, 'signed' => false]) + ->addColumn('alias', 'string', ['length' => 100, 'null' => false]) + ->addColumn('usuario', 'string', ['length' => 100, 'null' => false]) + ->addColumn('contraseƱa', 'string', ['length' => 100, 'null' => false]) + ->addForeignKey('inmobiliaria_rut', 'inmobiliaria', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080041_create_locations.php b/app/resources/database/migrations/20141101080041_create_locations.php new file mode 100644 index 0000000..38588bd --- /dev/null +++ b/app/resources/database/migrations/20141101080041_create_locations.php @@ -0,0 +1,19 @@ +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('locations') + ->addColumn('controller', 'string', ['length' => 50, 'null' => false]) + ->addColumn('action', 'string', ['length' => 100, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080042_create_logins.php b/app/resources/database/migrations/20141101080042_create_logins.php new file mode 100644 index 0000000..a74d605 --- /dev/null +++ b/app/resources/database/migrations/20141101080042_create_logins.php @@ -0,0 +1,23 @@ +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('logins') + ->addColumn('user_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('time', 'datetime', ['null' => false]) + ->addColumn('selector', 'string', ['length' => 255, 'null' => false]) + ->addColumn('token', 'string', ['length' => 255, 'null' => false]) + ->addColumn('status', 'integer', ['length' => 1, 'default' => 1, 'null' => false]) + ->addForeignKey('user_id', 'users', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080044_create_movimientos.php b/app/resources/database/migrations/20141101080044_create_movimientos.php new file mode 100644 index 0000000..21ec94b --- /dev/null +++ b/app/resources/database/migrations/20141101080044_create_movimientos.php @@ -0,0 +1,25 @@ +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('movimientos') + ->addColumn('cuenta_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('glosa', 'text', ['null' => false]) + ->addColumn('documento', 'string', ['length' => 50, 'null' => false]) + ->addColumn('cargo', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('abono', 'bigint', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('saldo', 'bigint', ['length' => 20, 'default' => 0, 'null' => false]) + ->addForeignKey('cuenta_id', 'cuenta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080045_create_movimientos_detalles.php b/app/resources/database/migrations/20141101080045_create_movimientos_detalles.php new file mode 100644 index 0000000..bb9f0ba --- /dev/null +++ b/app/resources/database/migrations/20141101080045_create_movimientos_detalles.php @@ -0,0 +1,27 @@ +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('movimientos_detalles') + ->addColumn('movimiento_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('centro_costo_id', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('categoria', 'string', ['length' => 100, 'default' => null, 'null' => true]) + ->addColumn('detalle', 'text', ['default' => null, 'null' => true]) + ->addColumn('rut', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('digito', 'string', ['length' => 1, 'default' => null, 'null' => true]) + ->addColumn('nombres', 'string', ['length' => 255, 'default' => null, 'null' => true]) + ->addColumn('identificador', 'string', ['length' => 100, 'default' => null, 'null' => true]) + ->addForeignKey('movimiento_id', 'movimientos', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('centro_costo_id', 'centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080046_create_pagare.php b/app/resources/database/migrations/20141101080046_create_pagare.php new file mode 100644 index 0000000..cb06831 --- /dev/null +++ b/app/resources/database/migrations/20141101080046_create_pagare.php @@ -0,0 +1,29 @@ +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('pagare') + ->addColumn('proyecto', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('moneda', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('capital', 'double', ['default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('tasa', 'double', ['default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('fecha_banco', 'date', ['default' => '0000-00-00', 'null' => false]) + ->addColumn('duracion', 'integer', ['length' => 10, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('uf', 'double', ['default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('abonado', 'integer', ['length' => 10, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('estado_pago', 'integer', ['length' => 10, 'default' => 99999999, 'null' => false, 'signed' => false]) + ->addForeignKey('moneda', 'tipo_moneda_pagare', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080047_create_pago.php b/app/resources/database/migrations/20141101080047_create_pago.php new file mode 100644 index 0000000..3a6eb7b --- /dev/null +++ b/app/resources/database/migrations/20141101080047_create_pago.php @@ -0,0 +1,25 @@ +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('pago') + ->addColumn('valor', 'double', ['null' => false]) + ->addColumn('banco', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('tipo', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('identificador', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('fecha', 'date', ['default' => null, 'null' => true]) + ->addColumn('uf', 'double', ['default' => null, 'null' => true]) + ->addColumn('pagador', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('asociado', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080048_create_pagos_centros_costos.php b/app/resources/database/migrations/20141101080048_create_pagos_centros_costos.php new file mode 100644 index 0000000..ef1c182 --- /dev/null +++ b/app/resources/database/migrations/20141101080048_create_pagos_centros_costos.php @@ -0,0 +1,21 @@ +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('pagos_centros_costos') + ->addColumn('pago_id', 'integer', ['length' => 11, 'null' => false, 'signed' => false]) + ->addColumn('centro_costo_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('pago_id', 'pago', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('centro_costo_id', 'centros_costos', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080049_create_permissions.php b/app/resources/database/migrations/20141101080049_create_permissions.php new file mode 100644 index 0000000..8d11c54 --- /dev/null +++ b/app/resources/database/migrations/20141101080049_create_permissions.php @@ -0,0 +1,21 @@ +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('permissions') + ->addColumn('type', 'integer', ['length' => 1, 'null' => false, 'signed' => false]) + ->addColumn('ext_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('action_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('status', 'integer', ['length' => 1, 'default' => 1, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080052_create_pie.php b/app/resources/database/migrations/20141101080052_create_pie.php new file mode 100644 index 0000000..2116ca1 --- /dev/null +++ b/app/resources/database/migrations/20141101080052_create_pie.php @@ -0,0 +1,23 @@ +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('pie') + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('valor', 'double', ['null' => false, 'signed' => false]) + ->addColumn('uf', 'double', ['default' => null, 'null' => true, 'signed' => false]) + ->addColumn('cuotas', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('asociado', 'integer', ['length' => 11, 'default' => 0]) + ->addColumn('reajuste', 'integer', ['length' => 11, 'default' => null, 'null' => true, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080053_create_precio.php b/app/resources/database/migrations/20141101080053_create_precio.php new file mode 100644 index 0000000..d1ac520 --- /dev/null +++ b/app/resources/database/migrations/20141101080053_create_precio.php @@ -0,0 +1,20 @@ +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('precio') + ->addColumn('unidad', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('valor', 'double', ['null' => false]) + ->addForeignKey('unidad', 'unidad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080054_create_problema.php b/app/resources/database/migrations/20141101080054_create_problema.php new file mode 100644 index 0000000..387a3ca --- /dev/null +++ b/app/resources/database/migrations/20141101080054_create_problema.php @@ -0,0 +1,19 @@ +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('problema') + ->addColumn('venta', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('descripcion', 'mediumtext', ['default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080055_create_promocion.php b/app/resources/database/migrations/20141101080055_create_promocion.php new file mode 100644 index 0000000..9b1622f --- /dev/null +++ b/app/resources/database/migrations/20141101080055_create_promocion.php @@ -0,0 +1,22 @@ +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('promocion') + ->addColumn('proyecto', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->addColumn('titulo', 'string', ['length' => 20, 'null' => false]) + ->addColumn('fecha_inicio', 'date', ['null' => false]) + ->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080056_create_promocion_venta.php b/app/resources/database/migrations/20141101080056_create_promocion_venta.php new file mode 100644 index 0000000..cadb54b --- /dev/null +++ b/app/resources/database/migrations/20141101080056_create_promocion_venta.php @@ -0,0 +1,21 @@ +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('promocion_venta', ['id' => '`promocion`,`venta`']) + ->addColumn('promocion', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('venta', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('valor', 'double', ['null' => false, 'signed' => false]) + ->addForeignKey('promocion', 'promocion', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080057_create_propiedad.php b/app/resources/database/migrations/20141101080057_create_propiedad.php new file mode 100644 index 0000000..1ea0e6a --- /dev/null +++ b/app/resources/database/migrations/20141101080057_create_propiedad.php @@ -0,0 +1,22 @@ +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('propiedad') + ->addColumn('unidad_principal', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('estacionamientos', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('bodegas', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('estado', 'integer', ['length' => 11, 'default' => 1]) + ->addForeignKey('unidad_principal', 'unidad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080058_create_propiedad_unidad.php b/app/resources/database/migrations/20141101080058_create_propiedad_unidad.php new file mode 100644 index 0000000..4a86909 --- /dev/null +++ b/app/resources/database/migrations/20141101080058_create_propiedad_unidad.php @@ -0,0 +1,23 @@ +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('propiedad_unidad') + ->addColumn('propiedad', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('unidad', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('principal', 'integer', ['length' => 1, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('valor', 'double', ['default' => 0, 'null' => false, 'signed' => false]) + ->addForeignKey('unidad', 'unidad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('propiedad', 'propiedad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080059_create_propietario.php b/app/resources/database/migrations/20141101080059_create_propietario.php new file mode 100644 index 0000000..2941100 --- /dev/null +++ b/app/resources/database/migrations/20141101080059_create_propietario.php @@ -0,0 +1,30 @@ +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;'); + } +} diff --git a/app/resources/database/migrations/20141101080101_create_provincia.php b/app/resources/database/migrations/20141101080101_create_provincia.php new file mode 100644 index 0000000..d2d6aee --- /dev/null +++ b/app/resources/database/migrations/20141101080101_create_provincia.php @@ -0,0 +1,20 @@ +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('provincia') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->addColumn('region', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('region', 'region', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080102_create_proyectista.php b/app/resources/database/migrations/20141101080102_create_proyectista.php new file mode 100644 index 0000000..37592bc --- /dev/null +++ b/app/resources/database/migrations/20141101080102_create_proyectista.php @@ -0,0 +1,24 @@ +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('proyectista') + ->addColumn('rut', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('nombre', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('tipo', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('representante', 'string', ['length' => 255, 'default' => null, 'null' => true]) + ->addColumn('telefono', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('correo', 'string', ['length' => 100, 'default' => null, 'null' => true]) + ->addColumn('direccion', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080103_create_proyectistas.php b/app/resources/database/migrations/20141101080103_create_proyectistas.php new file mode 100644 index 0000000..c2ce210 --- /dev/null +++ b/app/resources/database/migrations/20141101080103_create_proyectistas.php @@ -0,0 +1,20 @@ +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('proyectistas') + ->addColumn('proyecto', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('proyectista', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('fecha', 'date', ['default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080104_create_proyecto.php b/app/resources/database/migrations/20141101080104_create_proyecto.php new file mode 100644 index 0000000..c0c472b --- /dev/null +++ b/app/resources/database/migrations/20141101080104_create_proyecto.php @@ -0,0 +1,27 @@ +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('proyecto') + ->addColumn('inmobiliaria', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('descripcion', 'mediumtext', ['null' => false]) + ->addColumn('direccion', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('superficie_terreno', 'float', ['default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('valor_terreno', 'float', ['default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('corredor', 'float', ['default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('superficie_sobre_nivel', 'float', ['default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('superficie_bajo_nivel', 'float', ['default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('pisos', 'integer', ['length' => 10, 'default' => 0, 'null' => false, 'signed' => false]) + ->addColumn('subterraneos', 'integer', ['length' => 10, 'default' => 0, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080105_create_proyecto_agente.php b/app/resources/database/migrations/20141101080105_create_proyecto_agente.php new file mode 100644 index 0000000..4334fd8 --- /dev/null +++ b/app/resources/database/migrations/20141101080105_create_proyecto_agente.php @@ -0,0 +1,21 @@ +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('proyecto_agente') + ->addColumn('proyecto', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('agente', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('fecha', 'date', ['default' => null, 'null' => true]) + ->addColumn('comision', 'float', ['default' => 0]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080106_create_proyecto_terreno.php b/app/resources/database/migrations/20141101080106_create_proyecto_terreno.php new file mode 100644 index 0000000..adcd1b9 --- /dev/null +++ b/app/resources/database/migrations/20141101080106_create_proyecto_terreno.php @@ -0,0 +1,23 @@ +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('proyecto_terreno') + ->addColumn('proyecto_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('valor', 'double', ['null' => false]) + ->addColumn('tipo_moneda_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('proyecto_id', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('tipo_moneda_id', 'tipo_moneda_pagare', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080107_create_proyecto_tipo_unidad.php b/app/resources/database/migrations/20141101080107_create_proyecto_tipo_unidad.php new file mode 100644 index 0000000..ee9700b --- /dev/null +++ b/app/resources/database/migrations/20141101080107_create_proyecto_tipo_unidad.php @@ -0,0 +1,26 @@ +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('proyecto_tipo_unidad') + ->addColumn('proyecto', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('tipo', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('nombre', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('abreviacion', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('m2', 'float', ['default' => null, 'null' => true]) + ->addColumn('logia', 'float', ['default' => 0]) + ->addColumn('terraza', 'float', ['default' => 0]) + ->addColumn('descripcion', 'mediumtext', ['default' => null, 'null' => true]) + ->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080108_create_region.php b/app/resources/database/migrations/20141101080108_create_region.php new file mode 100644 index 0000000..20a4d62 --- /dev/null +++ b/app/resources/database/migrations/20141101080108_create_region.php @@ -0,0 +1,20 @@ +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('region') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->addColumn('numeral', 'char', ['length' => 4, 'null' => false]) + ->addColumn('numeracion', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080109_create_registries.php b/app/resources/database/migrations/20141101080109_create_registries.php new file mode 100644 index 0000000..424e653 --- /dev/null +++ b/app/resources/database/migrations/20141101080109_create_registries.php @@ -0,0 +1,21 @@ +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('registries') + ->addColumn('user', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('action', 'string', ['length' => 255, 'null' => false]) + ->addColumn('time', 'datetime', ['default' => '0000-00-00', 'null' => false]) + ->addForeignKey('user', 'users', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080110_create_registry_data.php b/app/resources/database/migrations/20141101080110_create_registry_data.php new file mode 100644 index 0000000..e24360e --- /dev/null +++ b/app/resources/database/migrations/20141101080110_create_registry_data.php @@ -0,0 +1,22 @@ +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('registry_data') + ->addColumn('registry', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('column', 'string', ['length' => 50, 'null' => false]) + ->addColumn('old', 'string', ['length' => 255, 'null' => false]) + ->addColumn('new', 'string', ['length' => 255, 'null' => false]) + ->addForeignKey('registry', 'registries', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080111_create_relacion_agentes.php b/app/resources/database/migrations/20141101080111_create_relacion_agentes.php new file mode 100644 index 0000000..aa05985 --- /dev/null +++ b/app/resources/database/migrations/20141101080111_create_relacion_agentes.php @@ -0,0 +1,19 @@ +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('relacion_agentes') + ->addColumn('agente1', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('agente2', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080112_create_relacion_inmobiliarias.php b/app/resources/database/migrations/20141101080112_create_relacion_inmobiliarias.php new file mode 100644 index 0000000..5100dcc --- /dev/null +++ b/app/resources/database/migrations/20141101080112_create_relacion_inmobiliarias.php @@ -0,0 +1,19 @@ +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('relacion_inmobiliarias') + ->addColumn('padre', 'integer', ['length' => 11, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('hijo', 'integer', ['length' => 11, 'default' => null, 'null' => true, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080113_create_remote_ip.php b/app/resources/database/migrations/20141101080113_create_remote_ip.php new file mode 100644 index 0000000..64a0186 --- /dev/null +++ b/app/resources/database/migrations/20141101080113_create_remote_ip.php @@ -0,0 +1,20 @@ +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('remote_ip') + ->addColumn('host', 'string', ['length' => 100, 'null' => false]) + ->addColumn('ip', 'string', ['length' => 15, 'null' => false]) + ->addColumn('updated', 'timestamp', ['default' => 'current_timestamp()', 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080114_create_renovacion_pagare.php b/app/resources/database/migrations/20141101080114_create_renovacion_pagare.php new file mode 100644 index 0000000..724e7f2 --- /dev/null +++ b/app/resources/database/migrations/20141101080114_create_renovacion_pagare.php @@ -0,0 +1,26 @@ +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('renovacion_pagare') + ->addColumn('pagare', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('insoluto', 'double', ['null' => false, 'signed' => false]) + ->addColumn('intereses', 'double', ['null' => false, 'signed' => false]) + ->addColumn('tasa', 'double', ['null' => false, 'signed' => false]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('fecha_banco', 'date', ['null' => false]) + ->addColumn('uf', 'double', ['default' => 0, 'null' => false]) + ->addColumn('duracion', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('pagare', 'pagare', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080115_create_roles.php b/app/resources/database/migrations/20141101080115_create_roles.php new file mode 100644 index 0000000..edcd79e --- /dev/null +++ b/app/resources/database/migrations/20141101080115_create_roles.php @@ -0,0 +1,20 @@ +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('roles') + ->addColumn('description', 'string', ['length' => 50, 'null' => false]) + ->addColumn('level', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('inherits', 'integer', ['length' => 10, 'default' => 0, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080116_create_subsidio.php b/app/resources/database/migrations/20141101080116_create_subsidio.php new file mode 100644 index 0000000..3d6d384 --- /dev/null +++ b/app/resources/database/migrations/20141101080116_create_subsidio.php @@ -0,0 +1,19 @@ +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('subsidio') + ->addColumn('pago', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('subsidio', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080117_create_tipo_agente.php b/app/resources/database/migrations/20141101080117_create_tipo_agente.php new file mode 100644 index 0000000..44be7f1 --- /dev/null +++ b/app/resources/database/migrations/20141101080117_create_tipo_agente.php @@ -0,0 +1,21 @@ +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('tipo_agente') + ->addColumn('descripcion', 'string', ['length' => 100, 'default' => null, 'null' => true]) + ->addColumn('icono', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('color', 'string', ['length' => 6, 'default' => null, 'null' => true]) + ->addColumn('bgcolor', 'string', ['length' => 6, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080118_create_tipo_cobro.php b/app/resources/database/migrations/20141101080118_create_tipo_cobro.php new file mode 100644 index 0000000..6c59cf6 --- /dev/null +++ b/app/resources/database/migrations/20141101080118_create_tipo_cobro.php @@ -0,0 +1,23 @@ +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('tipo_cobro') + ->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('monto_base', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('modificador', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('monto_neto', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('operacion', 'integer', ['length' => 11, 'default' => null, 'null' => true]) + ->addColumn('mod', 'float', ['default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080119_create_tipo_elemento.php b/app/resources/database/migrations/20141101080119_create_tipo_elemento.php new file mode 100644 index 0000000..5979b09 --- /dev/null +++ b/app/resources/database/migrations/20141101080119_create_tipo_elemento.php @@ -0,0 +1,20 @@ +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('tipo_elemento') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->addColumn('abreviacion', 'string', ['length' => 10, 'null' => false]) + ->addColumn('orden', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080120_create_tipo_estado_cierre.php b/app/resources/database/migrations/20141101080120_create_tipo_estado_cierre.php new file mode 100644 index 0000000..c945410 --- /dev/null +++ b/app/resources/database/migrations/20141101080120_create_tipo_estado_cierre.php @@ -0,0 +1,19 @@ +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('tipo_estado_cierre') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->addColumn('vigente', 'integer', ['length' => 1, 'default' => 0, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080121_create_tipo_estado_cobro.php b/app/resources/database/migrations/20141101080121_create_tipo_estado_cobro.php new file mode 100644 index 0000000..f5ad195 --- /dev/null +++ b/app/resources/database/migrations/20141101080121_create_tipo_estado_cobro.php @@ -0,0 +1,18 @@ +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('tipo_estado_cobro') + ->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080122_create_tipo_estado_pago.php b/app/resources/database/migrations/20141101080122_create_tipo_estado_pago.php new file mode 100644 index 0000000..d7a65fa --- /dev/null +++ b/app/resources/database/migrations/20141101080122_create_tipo_estado_pago.php @@ -0,0 +1,19 @@ +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('tipo_estado_pago') + ->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('active', 'integer', ['length' => 1, 'default' => 0]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080123_create_tipo_estado_precio.php b/app/resources/database/migrations/20141101080123_create_tipo_estado_precio.php new file mode 100644 index 0000000..e0887ed --- /dev/null +++ b/app/resources/database/migrations/20141101080123_create_tipo_estado_precio.php @@ -0,0 +1,18 @@ +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('tipo_estado_precio') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080124_create_tipo_estado_proyecto.php b/app/resources/database/migrations/20141101080124_create_tipo_estado_proyecto.php new file mode 100644 index 0000000..aa67c21 --- /dev/null +++ b/app/resources/database/migrations/20141101080124_create_tipo_estado_proyecto.php @@ -0,0 +1,21 @@ +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('tipo_estado_proyecto') + ->addColumn('descripcion', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->addColumn('orden', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('etapa', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addForeignKey('etapa', 'etapa_proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080125_create_tipo_estado_proyecto_agente.php b/app/resources/database/migrations/20141101080125_create_tipo_estado_proyecto_agente.php new file mode 100644 index 0000000..686f45c --- /dev/null +++ b/app/resources/database/migrations/20141101080125_create_tipo_estado_proyecto_agente.php @@ -0,0 +1,18 @@ +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('tipo_estado_proyecto_agente') + ->addColumn('descripcion', 'string', ['length' => 255, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080126_create_tipo_estado_unidad_bloqueada.php b/app/resources/database/migrations/20141101080126_create_tipo_estado_unidad_bloqueada.php new file mode 100644 index 0000000..d04cb0e --- /dev/null +++ b/app/resources/database/migrations/20141101080126_create_tipo_estado_unidad_bloqueada.php @@ -0,0 +1,19 @@ +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('tipo_estado_unidad_bloqueada') + ->addColumn('descripcion', 'string', ['length' => 255, 'null' => false]) + ->addColumn('activo', 'integer', ['length' => 1, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080127_create_tipo_estado_venta.php b/app/resources/database/migrations/20141101080127_create_tipo_estado_venta.php new file mode 100644 index 0000000..72491b3 --- /dev/null +++ b/app/resources/database/migrations/20141101080127_create_tipo_estado_venta.php @@ -0,0 +1,19 @@ +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('tipo_estado_venta') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->addColumn('activa', 'integer', ['length' => 1, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080128_create_tipo_moneda_pagare.php b/app/resources/database/migrations/20141101080128_create_tipo_moneda_pagare.php new file mode 100644 index 0000000..66a86d2 --- /dev/null +++ b/app/resources/database/migrations/20141101080128_create_tipo_moneda_pagare.php @@ -0,0 +1,18 @@ +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('tipo_moneda_pagare') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080129_create_tipo_pago.php b/app/resources/database/migrations/20141101080129_create_tipo_pago.php new file mode 100644 index 0000000..d419ff4 --- /dev/null +++ b/app/resources/database/migrations/20141101080129_create_tipo_pago.php @@ -0,0 +1,18 @@ +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('tipo_pago') + ->addColumn('descripcion', 'string', ['length' => 50, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080130_create_tipo_proyectista.php b/app/resources/database/migrations/20141101080130_create_tipo_proyectista.php new file mode 100644 index 0000000..10a3e48 --- /dev/null +++ b/app/resources/database/migrations/20141101080130_create_tipo_proyectista.php @@ -0,0 +1,18 @@ +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('tipo_proyectista') + ->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080131_create_tipo_sociedad.php b/app/resources/database/migrations/20141101080131_create_tipo_sociedad.php new file mode 100644 index 0000000..196cc30 --- /dev/null +++ b/app/resources/database/migrations/20141101080131_create_tipo_sociedad.php @@ -0,0 +1,19 @@ +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('tipo_sociedad') + ->addColumn('descripcion', 'string', ['length' => 100, 'null' => false]) + ->addColumn('abreviacion', 'string', ['length' => 10, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080132_create_tipo_tipologia.php b/app/resources/database/migrations/20141101080132_create_tipo_tipologia.php new file mode 100644 index 0000000..a6aef26 --- /dev/null +++ b/app/resources/database/migrations/20141101080132_create_tipo_tipologia.php @@ -0,0 +1,24 @@ +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('tipo_tipologia') + ->addColumn('tipo', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('tipologia', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('cantidad', 'integer', ['length' => 10, 'null' => false]) + ->addColumn('elemento', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('elemento', 'tipo_elemento', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('tipologia', 'tipologia', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('tipo', 'proyecto_tipo_unidad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080133_create_tipo_unidad.php b/app/resources/database/migrations/20141101080133_create_tipo_unidad.php new file mode 100644 index 0000000..7bfc055 --- /dev/null +++ b/app/resources/database/migrations/20141101080133_create_tipo_unidad.php @@ -0,0 +1,19 @@ +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('tipo_unidad') + ->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('orden', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080134_create_tipo_valor_cierre.php b/app/resources/database/migrations/20141101080134_create_tipo_valor_cierre.php new file mode 100644 index 0000000..291fcb9 --- /dev/null +++ b/app/resources/database/migrations/20141101080134_create_tipo_valor_cierre.php @@ -0,0 +1,18 @@ +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('tipo_valor_cierre') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080135_create_tipologia.php b/app/resources/database/migrations/20141101080135_create_tipologia.php new file mode 100644 index 0000000..9518fa3 --- /dev/null +++ b/app/resources/database/migrations/20141101080135_create_tipologia.php @@ -0,0 +1,18 @@ +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('tipologia') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080136_create_tipos_centros_costos.php b/app/resources/database/migrations/20141101080136_create_tipos_centros_costos.php new file mode 100644 index 0000000..ea380ef --- /dev/null +++ b/app/resources/database/migrations/20141101080136_create_tipos_centros_costos.php @@ -0,0 +1,18 @@ +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('tipos_centros_costos') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080137_create_tipos_cuentas_costos.php b/app/resources/database/migrations/20141101080137_create_tipos_cuentas_costos.php new file mode 100644 index 0000000..b0d2c59 --- /dev/null +++ b/app/resources/database/migrations/20141101080137_create_tipos_cuentas_costos.php @@ -0,0 +1,18 @@ +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('tipos_cuentas_costos') + ->addColumn('descripcion', 'string', ['length' => 50, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080138_create_uf.php b/app/resources/database/migrations/20141101080138_create_uf.php new file mode 100644 index 0000000..c6fba65 --- /dev/null +++ b/app/resources/database/migrations/20141101080138_create_uf.php @@ -0,0 +1,19 @@ +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('uf', ['id' => '`fecha`']) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('valor', 'float', ['default' => null, 'null' => true]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080139_create_unidad.php b/app/resources/database/migrations/20141101080139_create_unidad.php new file mode 100644 index 0000000..0116fc0 --- /dev/null +++ b/app/resources/database/migrations/20141101080139_create_unidad.php @@ -0,0 +1,33 @@ +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('unidad') + ->addColumn('proyecto', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('tipo', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('subtipo', 'string', ['length' => 20, 'default' => null, 'null' => true]) + ->addColumn('piso', 'integer', ['length' => 11, 'null' => false]) + ->addColumn('descripcion', 'string', ['length' => 30, 'null' => false]) + ->addColumn('abreviacion', 'string', ['length' => 10, 'null' => false]) + ->addColumn('m2', 'float', ['default' => null, 'null' => true]) + ->addColumn('terraza', 'float', ['default' => null, 'null' => true]) + ->addColumn('cubierta', 'float', ['default' => 0]) + ->addColumn('logia', 'float', ['default' => null, 'null' => true]) + ->addColumn('orientacion', 'char', ['length' => 2, 'default' => null, 'null' => true]) + ->addColumn('costo_inmobiliaria', 'float', ['default' => 0]) + ->addColumn('pt', 'integer', ['length' => 11, 'null' => false, 'signed' => false]) + ->addColumn('valor', 'float', ['default' => null, 'null' => true]) + ->addForeignKey('proyecto', 'proyecto', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('pt', 'proyecto_tipo_unidad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080140_create_unidad_bloqueada.php b/app/resources/database/migrations/20141101080140_create_unidad_bloqueada.php new file mode 100644 index 0000000..17fdb7f --- /dev/null +++ b/app/resources/database/migrations/20141101080140_create_unidad_bloqueada.php @@ -0,0 +1,19 @@ +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('unidad_bloqueada') + ->addColumn('agente', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('unidad', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080141_create_unidad_cierre.php b/app/resources/database/migrations/20141101080141_create_unidad_cierre.php new file mode 100644 index 0000000..2e79264 --- /dev/null +++ b/app/resources/database/migrations/20141101080141_create_unidad_cierre.php @@ -0,0 +1,22 @@ +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('unidad_cierre') + ->addColumn('cierre', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('unidad', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('principal', 'integer', ['length' => 1, 'default' => 0, 'null' => false]) + ->addForeignKey('cierre', 'cierre', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('unidad', 'unidad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080142_create_unidad_prorrateo.php b/app/resources/database/migrations/20141101080142_create_unidad_prorrateo.php new file mode 100644 index 0000000..1a11ffd --- /dev/null +++ b/app/resources/database/migrations/20141101080142_create_unidad_prorrateo.php @@ -0,0 +1,20 @@ +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('unidad_prorrateo') + ->addColumn('unidad_id', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('prorrateo', 'double', ['null' => false]) + ->addForeignKey('unidad_id', 'unidad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080143_create_user_roles.php b/app/resources/database/migrations/20141101080143_create_user_roles.php new file mode 100644 index 0000000..0d21d3c --- /dev/null +++ b/app/resources/database/migrations/20141101080143_create_user_roles.php @@ -0,0 +1,21 @@ +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('user_roles') + ->addColumn('user', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('role', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addForeignKey('user', 'users', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('role', 'roles', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080144_create_users.php b/app/resources/database/migrations/20141101080144_create_users.php new file mode 100644 index 0000000..76a7a96 --- /dev/null +++ b/app/resources/database/migrations/20141101080144_create_users.php @@ -0,0 +1,20 @@ +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('users') + ->addColumn('name', 'string', ['length' => 50, 'null' => false]) + ->addColumn('password', 'string', ['length' => 255, 'default' => null, 'null' => true]) + ->addColumn('enabled', 'integer', ['length' => 1, 'default' => 1, 'null' => false]) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080145_create_valor_cierre.php b/app/resources/database/migrations/20141101080145_create_valor_cierre.php new file mode 100644 index 0000000..8c270f8 --- /dev/null +++ b/app/resources/database/migrations/20141101080145_create_valor_cierre.php @@ -0,0 +1,22 @@ +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('valor_cierre') + ->addColumn('cierre', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('tipo', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('valor', 'double', ['null' => false]) + ->addForeignKey('cierre', 'cierre', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('tipo', 'tipo_valor_cierre', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080146_create_venta.php b/app/resources/database/migrations/20141101080146_create_venta.php new file mode 100644 index 0000000..eff21a5 --- /dev/null +++ b/app/resources/database/migrations/20141101080146_create_venta.php @@ -0,0 +1,40 @@ +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('venta') + ->addColumn('propietario', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('propiedad', 'integer', ['length' => 10, 'null' => false, 'signed' => false]) + ->addColumn('pie', 'integer', ['length' => 10, 'default' => 0, 'signed' => false]) + ->addColumn('bono_pie', 'integer', ['length' => 11, 'default' => 0]) + ->addColumn('credito', 'integer', ['length' => 10, 'default' => 0, 'signed' => false]) + ->addColumn('escritura', 'integer', ['length' => 11, 'default' => 0]) + ->addColumn('subsidio', 'integer', ['length' => 11, 'default' => 0, 'signed' => false]) + ->addColumn('escriturado', 'date', ['default' => null, 'null' => true]) + ->addColumn('entrega', 'integer', ['length' => 11, 'default' => 0]) + ->addColumn('entregado', 'date', ['default' => null, 'null' => true]) + ->addColumn('fecha', 'date', ['null' => false]) + ->addColumn('valor_uf', 'double', ['null' => false, 'signed' => false]) + ->addColumn('estado', 'integer', ['length' => 11, 'default' => 1, 'null' => false]) + ->addColumn('fecha_ingreso', 'date', ['default' => null, 'null' => true]) + ->addColumn('avalchile', 'boolean', ['length' => 1, 'default' => 0]) + ->addColumn('agente', 'integer', ['length' => 10, 'default' => 0, 'signed' => false]) + ->addColumn('uf', 'double', ['default' => null, 'null' => true]) + ->addColumn('relacionado', 'integer', ['length' => 1, 'default' => 0]) + ->addColumn('promocion', 'integer', ['length' => 10, 'default' => 0, 'signed' => false]) + ->addColumn('resciliacion', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addColumn('devolucion', 'integer', ['length' => 10, 'default' => null, 'null' => true, 'signed' => false]) + ->addForeignKey('propiedad', 'propiedad', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('propietario', 'propietario', 'rut', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20141101080147_create_venta_abono_cuotas.php b/app/resources/database/migrations/20141101080147_create_venta_abono_cuotas.php new file mode 100644 index 0000000..8bc5a65 --- /dev/null +++ b/app/resources/database/migrations/20141101080147_create_venta_abono_cuotas.php @@ -0,0 +1,22 @@ +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('venta_abono_cuotas') + ->addColumn('venta_id', 'integer', ['length' => 11, 'null' => false, 'signed' => false]) + ->addColumn('pago_id', 'integer', ['length' => 11, 'null' => false, 'signed' => false]) + ->addColumn('numero', 'integer', ['length' => 11, 'default' => 1, 'null' => false, 'signed' => false]) + ->addForeignKey('venta_id', 'venta', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->addForeignKey('pago_id', 'pago', 'id', ['delete' => 'cascade', 'update' => 'cascade']) + ->create(); + $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); + } +} diff --git a/app/resources/database/migrations/20241113010315_incoviba_17303572256733fad_3df_01b.php b/app/resources/database/migrations/20241113010315_incoviba_17303572256733fad_3df_01b.php deleted file mode 100644 index 24585df..0000000 --- a/app/resources/database/migrations/20241113010315_incoviba_17303572256733fad_3df_01b.php +++ /dev/null @@ -1,4728 +0,0 @@ -execute('SET unique_checks=0; SET foreign_key_checks=0;'); - $this->execute("ALTER DATABASE CHARACTER SET 'utf8mb3';"); - $this->execute("ALTER DATABASE COLLATE='utf8mb3_general_ci';"); - $this->table('tipo_estado_cierre', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('vigente', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => 1, - 'signed' => false, - 'after' => 'descripcion', - ]) - ->create(); - $this->table('logins', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('user_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('time', 'datetime', [ - 'null' => false, - 'after' => 'user_id', - ]) - ->addColumn('selector', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'time', - ]) - ->addColumn('token', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'selector', - ]) - ->addColumn('status', 'integer', [ - 'null' => false, - 'default' => '1', - 'limit' => 1, - 'after' => 'token', - ]) - ->addIndex(['user_id'], [ - 'name' => 'fk_logins_users', - 'unique' => false, - ]) - ->addForeignKey('user_id', 'users', 'id', [ - 'constraint' => 'fk_logins_users', - 'update' => 'RESTRICT', - 'delete' => 'RESTRICT', - ]) - ->create(); - $this->table('propiedad_unidad', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('propiedad', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('unidad', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'propiedad', - ]) - ->addColumn('principal', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => 1, - 'signed' => false, - 'after' => 'unidad', - ]) - ->addColumn('valor', 'double', [ - 'null' => false, - 'default' => '0', - 'after' => 'principal', - ]) - ->addIndex(['unidad'], [ - 'name' => 'unidad', - 'unique' => false, - ]) - ->addIndex(['propiedad'], [ - 'name' => 'propiedad', - 'unique' => false, - ]) - ->addForeignKey('unidad', 'unidad', 'id', [ - 'constraint' => 'propiedad_unidad_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('propiedad', 'propiedad', 'id', [ - 'constraint' => 'propiedad_unidad_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('agente', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('tipo', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'id', - ]) - ->addColumn('rut', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'tipo', - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'rut', - ]) - ->addColumn('representante', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'descripcion', - ]) - ->addColumn('telefono', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'representante', - ]) - ->addColumn('correo', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'telefono', - ]) - ->addColumn('direccion', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'correo', - ]) - ->addColumn('giro', 'text', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::TEXT_MEDIUM, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'direccion', - ]) - ->addColumn('abreviacion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'giro', - ]) - ->addIndex(['tipo'], [ - 'name' => 'idx_tipo', - 'unique' => false, - ]) - ->create(); - $this->table('tipo_estado_proyecto_agente', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('unidad', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'proyecto', - ]) - ->addColumn('subtipo', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'tipo', - ]) - ->addColumn('piso', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'subtipo', - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 30, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'piso', - ]) - ->addColumn('abreviacion', 'string', [ - 'null' => false, - 'limit' => 10, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'descripcion', - ]) - ->addColumn('m2', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'abreviacion', - ]) - ->addColumn('terraza', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'm2', - ]) - ->addColumn('cubierta', 'float', [ - 'null' => true, - 'default' => '0', - 'after' => 'terraza', - ]) - ->addColumn('logia', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'cubierta', - ]) - ->addColumn('orientacion', 'char', [ - 'null' => true, - 'default' => null, - 'limit' => 2, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'logia', - ]) - ->addColumn('costo_inmobiliaria', 'float', [ - 'null' => true, - 'default' => '0', - 'after' => 'orientacion', - ]) - ->addColumn('pt', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'costo_inmobiliaria', - ]) - ->addColumn('valor', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'pt', - ]) - ->addIndex(['proyecto', 'descripcion', 'tipo'], [ - 'name' => 'idx_unidad', - 'unique' => false, - ]) - ->addIndex(['pt'], [ - 'name' => 'pt', - 'unique' => false, - ]) - ->addForeignKey('proyecto', 'proyecto', 'id', [ - 'constraint' => 'unidad_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('pt', 'proyecto_tipo_unidad', 'id', [ - 'constraint' => 'unidad_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('promocion', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'proyecto', - ]) - ->addColumn('titulo', 'string', [ - 'null' => false, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'descripcion', - ]) - ->addColumn('fecha_inicio', 'date', [ - 'null' => false, - 'after' => 'titulo', - ]) - ->addIndex(['proyecto'], [ - 'name' => 'fk_proyecto_promocion', - 'unique' => false, - ]) - ->addForeignKey('proyecto', 'proyecto', 'id', [ - 'constraint' => 'fk_proyecto_promocion', - 'update' => 'RESTRICT', - 'delete' => 'RESTRICT', - ]) - ->create(); - $this->table('propiedad', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('unidad_principal', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('estacionamientos', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'unidad_principal', - ]) - ->addColumn('bodegas', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'estacionamientos', - ]) - ->addColumn('estado', 'integer', [ - 'null' => true, - 'default' => '1', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'bodegas', - ]) - ->addIndex(['unidad_principal'], [ - 'name' => 'fk_unidad_principal', - 'unique' => false, - ]) - ->addForeignKey('unidad_principal', 'unidad', 'id', [ - 'constraint' => 'fk_unidad_principal', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('tipo_sociedad', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('abreviacion', 'string', [ - 'null' => false, - 'limit' => 10, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'descripcion', - ]) - ->create(); - $this->table('tipo_estado_pago', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('active', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 1, - 'after' => 'descripcion', - ]) - ->create(); - $this->table('backup', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('date', 'datetime', [ - 'null' => true, - 'default' => null, - 'after' => 'id', - ]) - ->create(); - $this->table('categorias_centros_costos', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('users', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('name', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('password', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'name', - ]) - ->addColumn('enabled', 'integer', [ - 'null' => false, - 'default' => '1', - 'limit' => 1, - 'after' => 'password', - ]) - ->create(); - $this->table('credito', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('banco', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('valor', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'banco', - ]) - ->addColumn('fecha', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'valor', - ]) - ->addColumn('uf', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'fecha', - ]) - ->addColumn('abonado', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 1, - 'after' => 'uf', - ]) - ->addColumn('fecha_abono', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'abonado', - ]) - ->addColumn('pago', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'fecha_abono', - ]) - ->create(); - $this->table('tipos_cuentas_costos', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('remote_ip', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('host', 'string', [ - 'null' => false, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('ip', 'string', [ - 'null' => false, - 'limit' => 15, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'host', - ]) - ->addColumn('updated', 'timestamp', [ - 'null' => false, - 'default' => 'current_timestamp()', - 'update' => 'CURRENT_TIMESTAMP', - 'after' => 'ip', - ]) - ->create(); - $this->table('estado_precio', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('precio', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'precio', - ]) - ->addColumn('estado', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'fecha', - ]) - ->addIndex(['precio'], [ - 'name' => 'precio', - 'unique' => false, - ]) - ->addIndex(['estado'], [ - 'name' => 'estado', - 'unique' => false, - ]) - ->addForeignKey('precio', 'precio', 'id', [ - 'constraint' => 'estado_precio_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('estado', 'tipo_estado_precio', 'id', [ - 'constraint' => 'estado_precio_ibfk_4', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('tipo_estado_precio', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('movimientos', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('cuenta_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'cuenta_id', - ]) - ->addColumn('glosa', 'text', [ - 'null' => false, - 'limit' => 65535, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'fecha', - ]) - ->addColumn('documento', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'glosa', - ]) - ->addColumn('cargo', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => MysqlAdapter::INT_BIG, - 'signed' => false, - 'after' => 'documento', - ]) - ->addColumn('abono', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => MysqlAdapter::INT_BIG, - 'signed' => false, - 'after' => 'cargo', - ]) - ->addColumn('saldo', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => MysqlAdapter::INT_BIG, - 'after' => 'abono', - ]) - ->addIndex(['cuenta_id'], [ - 'name' => 'cuenta_id', - 'unique' => false, - ]) - ->addForeignKey('cuenta_id', 'cuenta', 'id', [ - 'constraint' => 'movimientos_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('user_roles', [ - 'id' => false, - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('user', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('role', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'user', - ]) - ->addIndex(['user'], [ - 'name' => 'user', - 'unique' => false, - ]) - ->addIndex(['role'], [ - 'name' => 'role', - 'unique' => false, - ]) - ->addForeignKey('user', 'users', 'id', [ - 'constraint' => 'user_roles_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('role', 'roles', 'id', [ - 'constraint' => 'user_roles_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('precio', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('unidad', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('valor', 'double', [ - 'null' => false, - 'after' => 'unidad', - ]) - ->addIndex(['unidad'], [ - 'name' => 'unidad', - 'unique' => false, - ]) - ->addForeignKey('unidad', 'unidad', 'id', [ - 'constraint' => 'precio_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('bono_pie', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('valor', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'id', - ]) - ->addColumn('pago', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'valor', - ]) - ->addIndex(['pago'], [ - 'name' => 'pago', - 'unique' => false, - ]) - ->addForeignKey('pago', 'pago', 'id', [ - 'constraint' => 'bono_pie_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('tipo_pago', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('estado_proyecto_agente', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('agente', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'agente', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'fecha', - ]) - ->create(); - $this->table('unidad_bloqueada', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('agente', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('unidad', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'agente', - ]) - ->create(); - $this->table('provincia', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('region', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'descripcion', - ]) - ->addIndex(['region'], [ - 'name' => 'fk_region', - 'unique' => false, - ]) - ->addForeignKey('region', 'region', 'id', [ - 'constraint' => 'fk_region', - 'update' => 'RESTRICT', - 'delete' => 'RESTRICT', - ]) - ->create(); - $this->table('configurations', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('name', 'string', [ - 'null' => false, - 'limit' => 30, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('value', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'name', - ]) - ->create(); - $this->table('pagos_centros_costos', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('pago_id', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('centro_costo_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'pago_id', - ]) - ->addIndex(['pago_id'], [ - 'name' => 'pago_id', - 'unique' => false, - ]) - ->addIndex(['centro_costo_id'], [ - 'name' => 'centro_costo_id', - 'unique' => false, - ]) - ->addForeignKey('pago_id', 'pago', 'id', [ - 'constraint' => 'pagos_centros_costos_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('centro_costo_id', 'centros_costos', 'id', [ - 'constraint' => 'pagos_centros_costos_ibfk_4', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('agente_tipo', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('agente', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'agente', - ]) - ->addIndex(['agente'], [ - 'name' => 'agente', - 'unique' => false, - ]) - ->addIndex(['tipo'], [ - 'name' => 'tipo', - 'unique' => false, - ]) - ->addForeignKey('agente', 'agente', 'id', [ - 'constraint' => 'agente_tipo_ibfk_1', - 'update' => 'RESTRICT', - 'delete' => 'NO_ACTION', - ]) - ->addForeignKey('tipo', 'tipo_agente', 'id', [ - 'constraint' => 'agente_tipo_ibfk_2', - 'update' => 'RESTRICT', - 'delete' => 'NO_ACTION', - ]) - ->create(); - $this->table('relacion_inmobiliarias', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('padre', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('hijo', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'padre', - ]) - ->create(); - $this->table('factura_proyecto_operador', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('operador_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'proyecto_id', - ]) - ->addColumn('factura', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'operador_id', - ]) - ->addColumn('valor_uf', 'double', [ - 'null' => false, - 'after' => 'factura', - ]) - ->addColumn('valor_neto', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'valor_uf', - ]) - ->addColumn('iva', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'valor_neto', - ]) - ->addIndex(['proyecto_id'], [ - 'name' => 'proyecto_id', - 'unique' => false, - ]) - ->addIndex(['operador_id'], [ - 'name' => 'operador_id', - 'unique' => false, - ]) - ->addForeignKey('proyecto_id', 'proyecto', 'id', [ - 'constraint' => 'factura_proyecto_operador_ibfk_1', - 'update' => 'RESTRICT', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('operador_id', 'agente', 'id', [ - 'constraint' => 'factura_proyecto_operador_ibfk_2', - 'update' => 'RESTRICT', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('tipo_unidad', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('orden', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'descripcion', - ]) - ->create(); - $this->table('factura_venta', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('factura_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('venta_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'factura_id', - ]) - ->addColumn('valor', 'double', [ - 'null' => false, - 'after' => 'venta_id', - ]) - ->addIndex(['factura_id'], [ - 'name' => 'factura_id', - 'unique' => false, - ]) - ->addIndex(['venta_id'], [ - 'name' => 'venta_id', - 'unique' => false, - ]) - ->addForeignKey('factura_id', 'factura_proyecto_operador', 'id', [ - 'constraint' => 'factura_venta_ibfk_1', - 'update' => 'RESTRICT', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('venta_id', 'venta', 'id', [ - 'constraint' => 'factura_venta_ibfk_2', - 'update' => 'RESTRICT', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('pagare', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('moneda', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'proyecto', - ]) - ->addColumn('capital', 'double', [ - 'null' => false, - 'default' => '0', - 'after' => 'moneda', - ]) - ->addColumn('tasa', 'double', [ - 'null' => false, - 'default' => '0', - 'after' => 'capital', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'tasa', - ]) - ->addColumn('fecha_banco', 'date', [ - 'null' => false, - 'default' => '0000-00-00', - 'after' => 'fecha', - ]) - ->addColumn('duracion', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'fecha_banco', - ]) - ->addColumn('uf', 'double', [ - 'null' => false, - 'default' => '0', - 'after' => 'duracion', - ]) - ->addColumn('abonado', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'uf', - ]) - ->addColumn('estado_pago', 'integer', [ - 'null' => false, - 'default' => '99999999', - 'limit' => 10, - 'signed' => false, - 'after' => 'abonado', - ]) - ->addIndex(['moneda'], [ - 'name' => 'moneda', - 'unique' => false, - ]) - ->addIndex(['proyecto'], [ - 'name' => 'proyecto', - 'unique' => false, - ]) - ->addForeignKey('moneda', 'tipo_moneda_pagare', 'id', [ - 'constraint' => 'pagare_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('proyecto', 'proyecto', 'id', [ - 'constraint' => 'pagare_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('facturas', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('venta_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('index', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'venta_id', - ]) - ->addColumn('proporcion', 'double', [ - 'null' => false, - 'after' => 'index', - ]) - ->addColumn('data', 'text', [ - 'null' => false, - 'limit' => 65535, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'proporcion', - ]) - ->addIndex(['venta_id'], [ - 'name' => 'venta_id', - 'unique' => false, - ]) - ->addForeignKey('venta_id', 'venta', 'id', [ - 'constraint' => 'facturas_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('cuenta', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('inmobiliaria', 'integer', [ - 'null' => false, - 'limit' => 8, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('banco', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'inmobiliaria', - ]) - ->addColumn('cuenta', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'banco', - ]) - ->addIndex(['inmobiliaria'], [ - 'name' => 'inmobiliaria', - 'unique' => false, - ]) - ->addIndex(['banco'], [ - 'name' => 'banco', - 'unique' => false, - ]) - ->addForeignKey('inmobiliaria', 'inmobiliaria', 'rut', [ - 'constraint' => 'cuenta_ibfk_1', - 'update' => 'RESTRICT', - 'delete' => 'NO_ACTION', - ]) - ->addForeignKey('banco', 'banco', 'id', [ - 'constraint' => 'cuenta_ibfk_2', - 'update' => 'RESTRICT', - 'delete' => 'NO_ACTION', - ]) - ->create(); - $this->table('cierre', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('precio', 'double', [ - 'null' => false, - 'after' => 'proyecto', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'precio', - ]) - ->addColumn('relacionado', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 1, - 'after' => 'fecha', - ]) - ->addColumn('propietario', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'relacionado', - ]) - ->addIndex(['proyecto'], [ - 'name' => 'proyecto', - 'unique' => false, - ]) - ->addForeignKey('proyecto', 'proyecto', 'id', [ - 'constraint' => 'cierre_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('uf', [ - 'id' => false, - 'primary_key' => ['fecha'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - ]) - ->addColumn('valor', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'fecha', - ]) - ->create(); - $this->table('tipo_cobro', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('monto_base', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'descripcion', - ]) - ->addColumn('modificador', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'monto_base', - ]) - ->addColumn('monto_neto', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'modificador', - ]) - ->addColumn('operacion', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'monto_neto', - ]) - ->addColumn('mod', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'operacion', - ]) - ->create(); - $this->table('tipo_valor_cierre', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('proyecto_terreno', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'proyecto_id', - ]) - ->addColumn('valor', 'double', [ - 'null' => false, - 'after' => 'fecha', - ]) - ->addColumn('tipo_moneda_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'valor', - ]) - ->addIndex(['proyecto_id'], [ - 'name' => 'proyecto_id', - 'unique' => false, - ]) - ->addIndex(['tipo_moneda_id'], [ - 'name' => 'tipo_moneda_id', - 'unique' => false, - ]) - ->addForeignKey('proyecto_id', 'proyecto', 'id', [ - 'constraint' => 'proyecto_terreno_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('tipo_moneda_id', 'tipo_moneda_pagare', 'id', [ - 'constraint' => 'proyecto_terreno_ibfk_4', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('comuna', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('provincia', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'descripcion', - ]) - ->addIndex(['provincia'], [ - 'name' => 'fk_provincia', - 'unique' => false, - ]) - ->addForeignKey('provincia', 'provincia', 'id', [ - 'constraint' => 'comuna_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('tipo_estado_venta', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('activa', 'integer', [ - 'null' => false, - 'limit' => 1, - 'signed' => false, - 'after' => 'descripcion', - ]) - ->create(); - $this->table('proyecto', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('inmobiliaria', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('descripcion', 'text', [ - 'null' => false, - 'limit' => MysqlAdapter::TEXT_MEDIUM, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'inmobiliaria', - ]) - ->addColumn('direccion', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'descripcion', - ]) - ->addColumn('superficie_terreno', 'float', [ - 'null' => false, - 'default' => '0', - 'after' => 'direccion', - ]) - ->addColumn('valor_terreno', 'float', [ - 'null' => false, - 'default' => '0', - 'after' => 'superficie_terreno', - ]) - ->addColumn('corredor', 'float', [ - 'null' => false, - 'default' => '0', - 'after' => 'valor_terreno', - ]) - ->addColumn('superficie_sobre_nivel', 'float', [ - 'null' => false, - 'default' => '0', - 'after' => 'corredor', - ]) - ->addColumn('superficie_bajo_nivel', 'float', [ - 'null' => false, - 'default' => '0', - 'after' => 'superficie_sobre_nivel', - ]) - ->addColumn('pisos', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'superficie_bajo_nivel', - ]) - ->addColumn('subterraneos', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'pisos', - ]) - ->create(); - $this->table('valor_cierre', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('cierre', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'cierre', - ]) - ->addColumn('valor', 'double', [ - 'null' => false, - 'after' => 'tipo', - ]) - ->addIndex(['cierre'], [ - 'name' => 'cierre', - 'unique' => false, - ]) - ->addIndex(['tipo'], [ - 'name' => 'tipo', - 'unique' => false, - ]) - ->addForeignKey('cierre', 'cierre', 'id', [ - 'constraint' => 'valor_cierre_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('tipo', 'tipo_valor_cierre', 'id', [ - 'constraint' => 'valor_cierre_ibfk_4', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('permissions', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('type', 'integer', [ - 'null' => false, - 'limit' => 1, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('ext_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'type', - ]) - ->addColumn('action_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'ext_id', - ]) - ->addColumn('status', 'integer', [ - 'null' => false, - 'default' => '1', - 'limit' => 1, - 'signed' => false, - 'after' => 'action_id', - ]) - ->create(); - $this->table('registries', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('user', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('action', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'user', - ]) - ->addColumn('time', 'datetime', [ - 'null' => false, - 'default' => '0000-00-00 00:00:00', - 'update' => 'CURRENT_TIMESTAMP', - 'after' => 'action', - ]) - ->addIndex(['user'], [ - 'name' => 'user', - 'unique' => false, - ]) - ->addForeignKey('user', 'users', 'id', [ - 'constraint' => 'registries_ibfk_1', - 'update' => 'RESTRICT', - 'delete' => 'NO_ACTION', - ]) - ->create(); - $this->table('cartolas', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('cuenta_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'cuenta_id', - ]) - ->addColumn('cargos', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => MysqlAdapter::INT_BIG, - 'signed' => false, - 'after' => 'fecha', - ]) - ->addColumn('abonos', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => MysqlAdapter::INT_BIG, - 'signed' => false, - 'after' => 'cargos', - ]) - ->addColumn('saldo', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => MysqlAdapter::INT_BIG, - 'after' => 'abonos', - ]) - ->addIndex(['cuenta_id'], [ - 'name' => 'cuenta_id', - 'unique' => false, - ]) - ->addForeignKey('cuenta_id', 'cuenta', 'id', [ - 'constraint' => 'cartolas_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('renovacion_pagare', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('pagare', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('insoluto', 'double', [ - 'null' => false, - 'after' => 'pagare', - ]) - ->addColumn('intereses', 'double', [ - 'null' => false, - 'after' => 'insoluto', - ]) - ->addColumn('tasa', 'double', [ - 'null' => false, - 'after' => 'intereses', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'tasa', - ]) - ->addColumn('fecha_banco', 'date', [ - 'null' => false, - 'after' => 'fecha', - ]) - ->addColumn('uf', 'double', [ - 'null' => false, - 'default' => '0', - 'after' => 'fecha_banco', - ]) - ->addColumn('duracion', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'uf', - ]) - ->addIndex(['pagare'], [ - 'name' => 'pagare', - 'unique' => false, - ]) - ->addForeignKey('pagare', 'pagare', 'id', [ - 'constraint' => 'renovacion_pagare_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('avance_construccion', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'proyecto', - ]) - ->addColumn('numero', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'fecha', - ]) - ->addColumn('avance', 'double', [ - 'null' => false, - 'after' => 'numero', - ]) - ->addColumn('estado_pago', 'double', [ - 'null' => false, - 'after' => 'avance', - ]) - ->addColumn('pagado', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'estado_pago', - ]) - ->addColumn('uf', 'double', [ - 'null' => true, - 'default' => null, - 'after' => 'pagado', - ]) - ->addColumn('fecha_pagado', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'uf', - ]) - ->addIndex(['proyecto'], [ - 'name' => 'proyecto', - 'unique' => false, - ]) - ->addForeignKey('proyecto', 'proyecto', 'id', [ - 'constraint' => 'avance_construccion_ibfk_1', - 'update' => 'RESTRICT', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('cobro', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'id', - ]) - ->addColumn('agente', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'proyecto', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'agente', - ]) - ->addColumn('fecha', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'tipo', - ]) - ->addColumn('valor', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'fecha', - ]) - ->addColumn('iva', 'float', [ - 'null' => true, - 'default' => '0', - 'after' => 'valor', - ]) - ->addColumn('uf', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'iva', - ]) - ->addColumn('identificador', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'uf', - ]) - ->addColumn('glosa', 'text', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::TEXT_MEDIUM, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'identificador', - ]) - ->create(); - $this->table('tipo_proyectista', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('cuota', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('pie', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'pie', - ]) - ->addColumn('valor_$', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'fecha', - ]) - ->addColumn('estado', 'boolean', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_TINY, - 'after' => 'valor_$', - ]) - ->addColumn('banco', 'string', [ - 'null' => false, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'estado', - ]) - ->addColumn('fecha_pago', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'banco', - ]) - ->addColumn('abonado', 'boolean', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_TINY, - 'after' => 'fecha_pago', - ]) - ->addColumn('fecha_abono', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'abonado', - ]) - ->addColumn('uf', 'double', [ - 'null' => true, - 'default' => '0', - 'after' => 'fecha_abono', - ]) - ->addColumn('pago', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'uf', - ]) - ->addColumn('numero', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'pago', - ]) - ->addIndex(['pago'], [ - 'name' => 'fk_pago_cuota', - 'unique' => false, - ]) - ->addIndex(['pie'], [ - 'name' => 'pie', - 'unique' => false, - ]) - ->addForeignKey('pago', 'pago', 'id', [ - 'constraint' => 'cuota_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('pie', 'pie', 'id', [ - 'constraint' => 'cuota_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('pago', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('valor', 'double', [ - 'null' => false, - 'after' => 'id', - ]) - ->addColumn('banco', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'valor', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'banco', - ]) - ->addColumn('identificador', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'tipo', - ]) - ->addColumn('fecha', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'identificador', - ]) - ->addColumn('uf', 'double', [ - 'null' => true, - 'default' => null, - 'after' => 'fecha', - ]) - ->addColumn('pagador', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'uf', - ]) - ->addColumn('asociado', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'pagador', - ]) - ->create(); - $this->table('etapa_proyecto', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('orden', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'descripcion', - ]) - ->create(); - $this->table('costo', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'id', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'proyecto', - ]) - ->addColumn('valor', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'tipo', - ]) - ->create(); - $this->table('unidad_cierre', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('cierre', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('unidad', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'cierre', - ]) - ->addColumn('principal', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => 1, - 'after' => 'unidad', - ]) - ->addIndex(['cierre'], [ - 'name' => 'cierre', - 'unique' => false, - ]) - ->addIndex(['unidad'], [ - 'name' => 'unidad', - 'unique' => false, - ]) - ->addForeignKey('cierre', 'cierre', 'id', [ - 'constraint' => 'unidad_cierre_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('unidad', 'unidad', 'id', [ - 'constraint' => 'unidad_cierre_ibfk_4', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('inmobiliaria', [ - 'id' => false, - 'primary_key' => ['rut'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('rut', 'integer', [ - 'null' => false, - 'limit' => 8, - 'signed' => false, - ]) - ->addColumn('dv', 'char', [ - 'null' => true, - 'default' => null, - 'limit' => 1, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'rut', - ]) - ->addColumn('razon', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'dv', - ]) - ->addColumn('abreviacion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'razon', - ]) - ->addColumn('cuenta', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'abreviacion', - ]) - ->addColumn('banco', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'cuenta', - ]) - ->addColumn('sociedad', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'banco', - ]) - ->addColumn('sigla', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 4, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'sociedad', - ]) - ->create(); - $this->table('region', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('numeral', 'char', [ - 'null' => false, - 'limit' => 4, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'descripcion', - ]) - ->addColumn('numeracion', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'numeral', - ]) - ->addIndex(['numeracion'], [ - 'name' => 'idx_region', - 'unique' => false, - ]) - ->create(); - $this->table('proyecto_tipo_unidad', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'proyecto', - ]) - ->addColumn('nombre', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'tipo', - ]) - ->addColumn('abreviacion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'nombre', - ]) - ->addColumn('m2', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'abreviacion', - ]) - ->addColumn('logia', 'float', [ - 'null' => true, - 'default' => '0', - 'after' => 'm2', - ]) - ->addColumn('terraza', 'float', [ - 'null' => true, - 'default' => '0', - 'after' => 'logia', - ]) - ->addColumn('descripcion', 'text', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::TEXT_MEDIUM, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'terraza', - ]) - ->addIndex(['proyecto'], [ - 'name' => 'fk_proyecto_pt', - 'unique' => false, - ]) - ->addForeignKey('proyecto', 'proyecto', 'id', [ - 'constraint' => 'fk_proyecto_pt', - 'update' => 'RESTRICT', - 'delete' => 'RESTRICT', - ]) - ->create(); - $this->table('relacion_agentes', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('agente1', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'id', - ]) - ->addColumn('agente2', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'agente1', - ]) - ->create(); - $this->table('subsidio', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('pago', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('subsidio', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'pago', - ]) - ->create(); - $this->table('proyecto_agente', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('agente', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'proyecto', - ]) - ->addColumn('fecha', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'agente', - ]) - ->addColumn('comision', 'float', [ - 'null' => true, - 'default' => '0', - 'after' => 'fecha', - ]) - ->create(); - $this->table('tipo_elemento', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('abreviacion', 'string', [ - 'null' => false, - 'limit' => 10, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'descripcion', - ]) - ->addColumn('orden', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'abreviacion', - ]) - ->create(); - $this->table('roles', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('description', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('level', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'description', - ]) - ->addColumn('inherits', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'level', - ]) - ->create(); - $this->table('propietario', [ - 'id' => false, - 'primary_key' => ['rut'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('rut', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('dv', 'char', [ - 'null' => false, - 'limit' => 1, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'rut', - ]) - ->addColumn('nombres', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'dv', - ]) - ->addColumn('apellido_paterno', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'nombres', - ]) - ->addColumn('apellido_materno', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'apellido_paterno', - ]) - ->addColumn('sexo', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 1, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'apellido_materno', - ]) - ->addColumn('estado_civil', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'sexo', - ]) - ->addColumn('profesion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'estado_civil', - ]) - ->addColumn('direccion', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'profesion', - ]) - ->addColumn('telefono', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'direccion', - ]) - ->addColumn('email', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'telefono', - ]) - ->addColumn('representante', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 10, - 'after' => 'email', - ]) - ->addColumn('otro', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'representante', - ]) - ->create(); - $this->table('estado_proyecto', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('estado', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'proyecto', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'estado', - ]) - ->addIndex(['proyecto'], [ - 'name' => 'proyecto', - 'unique' => false, - ]) - ->addIndex(['estado'], [ - 'name' => 'estado', - 'unique' => false, - ]) - ->addForeignKey('proyecto', 'proyecto', 'id', [ - 'constraint' => 'estado_proyecto_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('estado', 'tipo_estado_proyecto', 'id', [ - 'constraint' => 'estado_proyecto_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('banco', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('nombre', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('estado_venta', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('venta', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('estado', 'integer', [ - 'null' => false, - 'default' => '1', - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'venta', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'estado', - ]) - ->addIndex(['venta'], [ - 'name' => 'escritura', - 'unique' => false, - ]) - ->addIndex(['estado'], [ - 'name' => 'estado', - 'unique' => false, - ]) - ->addForeignKey('estado', 'tipo_estado_venta', 'id', [ - 'constraint' => 'estado_venta_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('venta', 'venta', 'id', [ - 'constraint' => 'estado_venta_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('estado_cobro', [ - 'id' => false, - 'primary_key' => ['id', 'cobro', 'estado'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('cobro', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'cobro', - ]) - ->addColumn('estado', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'fecha', - ]) - ->create(); - $this->table('estado_pago', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('pago', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'pago', - ]) - ->addColumn('estado', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'fecha', - ]) - ->addIndex(['estado'], [ - 'name' => 'estado', - 'unique' => false, - ]) - ->addForeignKey('estado', 'tipo_estado_pago', 'id', [ - 'constraint' => 'estado_pago_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('tipo_estado_unidad_bloqueada', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('activo', 'integer', [ - 'null' => false, - 'limit' => 1, - 'signed' => false, - 'after' => 'descripcion', - ]) - ->create(); - $this->table('venta', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('propietario', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('propiedad', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'propietario', - ]) - ->addColumn('pie', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'propiedad', - ]) - ->addColumn('bono_pie', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'pie', - ]) - ->addColumn('credito', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'bono_pie', - ]) - ->addColumn('escritura', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'credito', - ]) - ->addColumn('subsidio', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'escritura', - ]) - ->addColumn('escriturado', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'subsidio', - ]) - ->addColumn('entrega', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'escriturado', - ]) - ->addColumn('entregado', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'entrega', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'entregado', - ]) - ->addColumn('valor_uf', 'double', [ - 'null' => false, - 'after' => 'fecha', - ]) - ->addColumn('estado', 'integer', [ - 'null' => false, - 'default' => '1', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'valor_uf', - ]) - ->addColumn('fecha_ingreso', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'estado', - ]) - ->addColumn('avalchile', 'boolean', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_TINY, - 'after' => 'fecha_ingreso', - ]) - ->addColumn('agente', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'avalchile', - ]) - ->addColumn('uf', 'double', [ - 'null' => true, - 'default' => null, - 'after' => 'agente', - ]) - ->addColumn('relacionado', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 1, - 'after' => 'uf', - ]) - ->addColumn('promocion', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => 10, - 'signed' => false, - 'after' => 'relacionado', - ]) - ->addColumn('resciliacion', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'promocion', - ]) - ->addColumn('devolucion', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'resciliacion', - ]) - ->addIndex(['propietario'], [ - 'name' => 'idx_propietario', - 'unique' => false, - ]) - ->addIndex(['fecha'], [ - 'name' => 'idx_fecha', - 'unique' => false, - ]) - ->addIndex(['propiedad'], [ - 'name' => 'fk_propiedad_venta', - 'unique' => false, - ]) - ->addForeignKey('propiedad', 'propiedad', 'id', [ - 'constraint' => 'fk_propiedad_venta', - 'update' => 'RESTRICT', - 'delete' => 'RESTRICT', - ]) - ->addForeignKey('propietario', 'propietario', 'rut', [ - 'constraint' => 'venta_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('estado_cierre', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('cierre', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'cierre', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'tipo', - ]) - ->addIndex(['cierre'], [ - 'name' => 'cierre', - 'unique' => false, - ]) - ->addIndex(['tipo'], [ - 'name' => 'tipo', - 'unique' => false, - ]) - ->addForeignKey('cierre', 'cierre', 'id', [ - 'constraint' => 'estado_cierre_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('tipo', 'tipo_estado_cierre', 'id', [ - 'constraint' => 'estado_cierre_ibfk_4', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('proyectista', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('rut', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'id', - ]) - ->addColumn('nombre', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'rut', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'nombre', - ]) - ->addColumn('representante', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'tipo', - ]) - ->addColumn('telefono', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'representante', - ]) - ->addColumn('correo', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'telefono', - ]) - ->addColumn('direccion', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'correo', - ]) - ->create(); - $this->table('movimientos_detalles', [ - 'id' => false, - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('movimiento_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('centro_costo_id', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'movimiento_id', - ]) - ->addColumn('categoria', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'centro_costo_id', - ]) - ->addColumn('detalle', 'text', [ - 'null' => true, - 'default' => null, - 'limit' => 65535, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'categoria', - ]) - ->addColumn('rut', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'detalle', - ]) - ->addColumn('digito', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 1, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'rut', - ]) - ->addColumn('nombres', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'digito', - ]) - ->addColumn('identificador', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'nombres', - ]) - ->addIndex(['movimiento_id'], [ - 'name' => 'movimiento_id', - 'unique' => false, - ]) - ->addIndex(['centro_costo_id'], [ - 'name' => 'centro_costo_id', - 'unique' => false, - ]) - ->addForeignKey('movimiento_id', 'movimientos', 'id', [ - 'constraint' => 'movimientos_detalles_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('centro_costo_id', 'centros_costos', 'id', [ - 'constraint' => 'movimientos_detalles_ibfk_5', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('proyectistas', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('proyecto', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'id', - ]) - ->addColumn('proyectista', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'proyecto', - ]) - ->addColumn('fecha', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'proyectista', - ]) - ->create(); - $this->table('tipo_tipologia', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('tipo', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('tipologia', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'tipo', - ]) - ->addColumn('cantidad', 'integer', [ - 'null' => false, - 'limit' => 10, - 'after' => 'tipologia', - ]) - ->addColumn('elemento', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'cantidad', - ]) - ->addIndex(['elemento'], [ - 'name' => 'elemento', - 'unique' => false, - ]) - ->addIndex(['tipologia'], [ - 'name' => 'tipologia', - 'unique' => false, - ]) - ->addIndex(['tipo'], [ - 'name' => 'tipo', - 'unique' => false, - ]) - ->addForeignKey('elemento', 'tipo_elemento', 'id', [ - 'constraint' => 'tipo_tipologia_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('tipologia', 'tipologia', 'id', [ - 'constraint' => 'tipo_tipologia_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('tipo', 'proyecto_tipo_unidad', 'id', [ - 'constraint' => 'tipo_tipologia_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('depositos', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('cuenta_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('capital', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'cuenta_id', - ]) - ->addColumn('futuro', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'capital', - ]) - ->addColumn('inicio', 'date', [ - 'null' => false, - 'after' => 'futuro', - ]) - ->addColumn('termino', 'date', [ - 'null' => false, - 'after' => 'inicio', - ]) - ->addIndex(['cuenta_id'], [ - 'name' => 'cuenta_id', - 'unique' => false, - ]) - ->addForeignKey('cuenta_id', 'cuenta', 'id', [ - 'constraint' => 'depositos_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('unidad_prorrateo', [ - 'id' => false, - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('unidad_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('prorrateo', 'double', [ - 'null' => false, - 'after' => 'unidad_id', - ]) - ->addIndex(['unidad_id'], [ - 'name' => 'unidad_id', - 'unique' => false, - ]) - ->addForeignKey('unidad_id', 'unidad', 'id', [ - 'constraint' => 'unidad_prorrateo_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('escritura', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('valor', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_BIG, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'valor', - ]) - ->addColumn('uf', 'float', [ - 'null' => true, - 'default' => null, - 'after' => 'fecha', - ]) - ->addColumn('abonado', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'uf', - ]) - ->addColumn('fecha_abono', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'abonado', - ]) - ->addColumn('pago', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'fecha_abono', - ]) - ->create(); - $this->table('comentario', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('venta', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'datetime', [ - 'null' => true, - 'default' => null, - 'after' => 'venta', - ]) - ->addColumn('texto', 'blob', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::BLOB_REGULAR, - 'after' => 'fecha', - ]) - ->addColumn('estado', 'integer', [ - 'null' => true, - 'default' => '1', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'texto', - ]) - ->create(); - $this->table('estados_cuentas', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('cuenta_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'cuenta_id', - ]) - ->addColumn('active', 'boolean', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_TINY, - 'after' => 'fecha', - ]) - ->addIndex(['cuenta_id'], [ - 'name' => 'cuenta_id', - 'unique' => false, - ]) - ->addForeignKey('cuenta_id', 'cuenta', 'id', [ - 'constraint' => 'estados_cuentas_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('registry_data', [ - 'id' => false, - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => MysqlAdapter::INT_REGULAR, - ]) - ->addColumn('registry', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('column', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'registry', - ]) - ->addColumn('old', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'column', - ]) - ->addColumn('new', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'old', - ]) - ->addIndex(['registry'], [ - 'name' => 'registry', - 'unique' => false, - ]) - ->addForeignKey('registry', 'registries', 'id', [ - 'constraint' => 'registry_data_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('action', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('description', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('centros_costos', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('tipo_centro_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('categoria_id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'tipo_centro_id', - ]) - ->addColumn('tipo_cuenta_id', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'categoria_id', - ]) - ->addColumn('cuenta_contable', 'string', [ - 'null' => false, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'tipo_cuenta_id', - ]) - ->addColumn('descripcion', 'text', [ - 'null' => false, - 'limit' => MysqlAdapter::TEXT_MEDIUM, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'cuenta_contable', - ]) - ->addIndex(['tipo_centro_id'], [ - 'name' => 'tipo_centro_id', - 'unique' => false, - ]) - ->addIndex(['categoria_id'], [ - 'name' => 'categoria_id', - 'unique' => false, - ]) - ->addIndex(['tipo_cuenta_id'], [ - 'name' => 'tipo_cuenta_id', - 'unique' => false, - ]) - ->addForeignKey('tipo_centro_id', 'tipos_centros_costos', 'id', [ - 'constraint' => 'centros_costos_ibfk_3', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->addForeignKey('categoria_id', 'categorias_centros_costos', 'id', [ - 'constraint' => 'centros_costos_ibfk_4', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('estado_unidad_bloqueada', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('unidad', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'unidad', - ]) - ->addColumn('tipo', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'fecha', - ]) - ->create(); - $this->table('entrega', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'id', - ]) - ->addColumn('fondo_operacion', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'fecha', - ]) - ->addColumn('fondo_reserva', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'fondo_operacion', - ]) - ->addColumn('fecha_fondo_operacion', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'fondo_reserva', - ]) - ->addColumn('fecha_fondo_reserva', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'fecha_fondo_operacion', - ]) - ->addColumn('pago_operacion', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'fecha_fondo_reserva', - ]) - ->addColumn('pago_reserva', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'pago_operacion', - ]) - ->create(); - $this->table('promocion_venta', [ - 'id' => false, - 'primary_key' => ['promocion', 'venta'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('promocion', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - ]) - ->addColumn('venta', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'promocion', - ]) - ->addColumn('valor', 'double', [ - 'null' => false, - 'after' => 'venta', - ]) - ->addForeignKey('promocion', 'promocion', 'id', [ - 'constraint' => 'fk_promocion_venta', - 'update' => 'RESTRICT', - 'delete' => 'RESTRICT', - ]) - ->create(); - $this->table('monolog', [ - 'id' => false, - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('channel', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - ]) - ->addColumn('level', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'channel', - ]) - ->addColumn('message', 'text', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::TEXT_LONG, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'level', - ]) - ->addColumn('time', 'datetime', [ - 'null' => true, - 'default' => null, - 'after' => 'message', - ]) - ->addColumn('context', 'text', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::TEXT_LONG, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'time', - ]) - ->addColumn('extra', 'text', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::TEXT_LONG, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'context', - ]) - ->create(); - $this->table('inmobiliarias_nubox', [ - 'id' => false, - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('inmobiliaria_rut', 'integer', [ - 'null' => false, - 'limit' => 8, - 'signed' => false, - ]) - ->addColumn('alias', 'string', [ - 'null' => false, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'inmobiliaria_rut', - ]) - ->addColumn('usuario', 'string', [ - 'null' => false, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'alias', - ]) - ->addColumn('contraseƱa', 'string', [ - 'null' => false, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'usuario', - ]) - ->addIndex(['inmobiliaria_rut'], [ - 'name' => 'inmobiliaria_rut', - 'unique' => false, - ]) - ->addForeignKey('inmobiliaria_rut', 'inmobiliaria', 'rut', [ - 'constraint' => 'inmobiliarias_nubox_ibfk_2', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('locations', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('controller', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('action', 'string', [ - 'null' => false, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'controller', - ]) - ->create(); - $this->table('direccion', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('calle', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('numero', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'calle', - ]) - ->addColumn('extra', 'string', [ - 'null' => false, - 'limit' => 255, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'numero', - ]) - ->addColumn('comuna', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'extra', - ]) - ->addIndex(['comuna'], [ - 'name' => 'fk_comuna', - 'unique' => false, - ]) - ->addForeignKey('comuna', 'comuna', 'id', [ - 'constraint' => 'direccion_ibfk_1', - 'update' => 'CASCADE', - 'delete' => 'CASCADE', - ]) - ->create(); - $this->table('tipos_centros_costos', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('tipo_agente', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 100, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('icono', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'descripcion', - ]) - ->addColumn('color', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 6, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'icono', - ]) - ->addColumn('bgcolor', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 6, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'color', - ]) - ->create(); - $this->table('tipo_estado_proyecto', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->addColumn('orden', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'descripcion', - ]) - ->addColumn('etapa', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'signed' => false, - 'after' => 'orden', - ]) - ->addIndex(['etapa'], [ - 'name' => 'fk_etapa', - 'unique' => false, - ]) - ->addIndex(['orden'], [ - 'name' => 'idx_orden', - 'unique' => false, - ]) - ->addIndex(['descripcion'], [ - 'name' => 'idx_descripcion', - 'unique' => false, - ]) - ->addForeignKey('etapa', 'etapa_proyecto', 'id', [ - 'constraint' => 'fk_etapa', - 'update' => 'RESTRICT', - 'delete' => 'RESTRICT', - ]) - ->create(); - $this->table('estado_problema', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('problema', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'id', - ]) - ->addColumn('fecha', 'date', [ - 'null' => true, - 'default' => null, - 'after' => 'problema', - ]) - ->addColumn('estado', 'enum', [ - 'null' => true, - 'default' => null, - 'limit' => 10, - 'values' => ['ingreso', 'revision', 'correccion', 'ok'], - 'after' => 'fecha', - ]) - ->create(); - $this->table('problema', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('venta', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'id', - ]) - ->addColumn('descripcion', 'text', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::TEXT_MEDIUM, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'venta', - ]) - ->create(); - $this->table('tipo_estado_cobro', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => true, - 'default' => null, - 'limit' => 20, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('pie', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('fecha', 'date', [ - 'null' => false, - 'after' => 'id', - ]) - ->addColumn('valor', 'double', [ - 'null' => false, - 'after' => 'fecha', - ]) - ->addColumn('uf', 'double', [ - 'null' => true, - 'default' => null, - 'after' => 'valor', - ]) - ->addColumn('cuotas', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'after' => 'uf', - ]) - ->addColumn('asociado', 'integer', [ - 'null' => true, - 'default' => '0', - 'limit' => MysqlAdapter::INT_REGULAR, - 'after' => 'cuotas', - ]) - ->addColumn('reajuste', 'integer', [ - 'null' => true, - 'default' => null, - 'limit' => MysqlAdapter::INT_REGULAR, - 'signed' => false, - 'after' => 'asociado', - ]) - ->create(); - $this->table('tipo_moneda_pagare', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->table('tipologia', [ - 'id' => false, - 'primary_key' => ['id'], - 'engine' => 'InnoDB', - 'encoding' => 'utf8mb4', - 'collation' => 'utf8mb4_general_ci', - 'comment' => '', - 'row_format' => 'DYNAMIC', - ]) - ->addColumn('id', 'integer', [ - 'null' => false, - 'limit' => 10, - 'signed' => false, - 'identity' => true, - ]) - ->addColumn('descripcion', 'string', [ - 'null' => false, - 'limit' => 50, - 'collation' => 'utf8mb4_general_ci', - 'encoding' => 'utf8mb4', - 'after' => 'id', - ]) - ->create(); - $this->execute('SET unique_checks=1; SET foreign_key_checks=1;'); - } -} diff --git a/app/resources/database/schema.sql b/app/resources/database/schema.sql deleted file mode 100644 index 3ee8e7f..0000000 --- a/app/resources/database/schema.sql +++ /dev/null @@ -1,677 +0,0 @@ --- Adminer 4.8.1 MySQL 11.5.2-MariaDB-ubu2404 dump - -SET NAMES utf8; -SET time_zone = '+00:00'; -SET foreign_key_checks = 0; -SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; - -USE `incoviba`; - -SET NAMES utf8mb4; - -DROP TABLE IF EXISTS `action`; -CREATE TABLE `action` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `description` varchar(50) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `agente`; -CREATE TABLE `agente` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `tipo` int(11) DEFAULT NULL, - `rut` int(11) DEFAULT NULL, - `descripcion` varchar(100) DEFAULT NULL, - `representante` varchar(100) DEFAULT NULL, - `telefono` int(11) DEFAULT NULL, - `correo` varchar(50) DEFAULT NULL, - `direccion` int(11) DEFAULT NULL, - `giro` mediumtext DEFAULT NULL, - `abreviacion` varchar(20) DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `idx_tipo` (`tipo`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `agente_tipo`; -CREATE TABLE `agente_tipo` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `agente` int(10) unsigned NOT NULL, - `tipo` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `agente` (`agente`), - KEY `tipo` (`tipo`), - CONSTRAINT `agente_tipo_ibfk_1` FOREIGN KEY (`agente`) REFERENCES `agente` (`id`) ON DELETE NO ACTION, - CONSTRAINT `agente_tipo_ibfk_2` FOREIGN KEY (`tipo`) REFERENCES `tipo_agente` (`id`) ON DELETE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `avance_construccion`; -CREATE TABLE `avance_construccion` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `proyecto` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - `numero` int(10) unsigned NOT NULL, - `avance` double unsigned NOT NULL, - `estado_pago` double unsigned NOT NULL, - `pagado` int(10) unsigned DEFAULT NULL, - `uf` double unsigned DEFAULT NULL, - `fecha_pagado` date DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `proyecto` (`proyecto`), - CONSTRAINT `avance_construccion_ibfk_1` FOREIGN KEY (`proyecto`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `backup`; -CREATE TABLE `backup` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `date` datetime DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `banco`; -CREATE TABLE `banco` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `nombre` varchar(20) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `bono_pie`; -CREATE TABLE `bono_pie` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `valor` float DEFAULT NULL, - `pago` int(11) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `pago` (`pago`), - CONSTRAINT `bono_pie_ibfk_1` FOREIGN KEY (`pago`) REFERENCES `pago` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `cartolas`; -CREATE TABLE `cartolas` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `cuenta_id` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - `cargos` bigint(20) unsigned NOT NULL DEFAULT 0, - `abonos` bigint(20) unsigned NOT NULL DEFAULT 0, - `saldo` bigint(20) NOT NULL DEFAULT 0, - PRIMARY KEY (`id`), - KEY `cuenta_id` (`cuenta_id`), - CONSTRAINT `cartolas_ibfk_2` FOREIGN KEY (`cuenta_id`) REFERENCES `cuenta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `categorias_centros_costos`; -CREATE TABLE `categorias_centros_costos` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `descripcion` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `centros_costos`; -CREATE TABLE `centros_costos` ( - `id` int(10) unsigned NOT NULL, - `tipo_centro_id` int(10) unsigned NOT NULL, - `categoria_id` int(10) unsigned NOT NULL, - `tipo_cuenta_id` int(10) unsigned DEFAULT NULL, - `cuenta_contable` varchar(100) NOT NULL, - `descripcion` mediumtext NOT NULL, - PRIMARY KEY (`id`), - KEY `tipo_centro_id` (`tipo_centro_id`), - KEY `categoria_id` (`categoria_id`), - KEY `tipo_cuenta_id` (`tipo_cuenta_id`), - CONSTRAINT `centros_costos_ibfk_3` FOREIGN KEY (`tipo_centro_id`) REFERENCES `tipos_centros_costos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `centros_costos_ibfk_4` FOREIGN KEY (`categoria_id`) REFERENCES `categorias_centros_costos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `cierre`; -CREATE TABLE `cierre` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `proyecto` int(10) unsigned NOT NULL, - `precio` double NOT NULL, - `fecha` date NOT NULL, - `relacionado` int(1) DEFAULT 0, - `propietario` int(10) unsigned DEFAULT 0, - PRIMARY KEY (`id`), - KEY `proyecto` (`proyecto`), - CONSTRAINT `cierre_ibfk_2` FOREIGN KEY (`proyecto`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `cobro`; -CREATE TABLE `cobro` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `proyecto` int(11) DEFAULT NULL, - `agente` int(11) DEFAULT NULL, - `tipo` int(11) DEFAULT NULL, - `fecha` date DEFAULT NULL, - `valor` float DEFAULT NULL, - `iva` float DEFAULT 0, - `uf` float DEFAULT NULL, - `identificador` varchar(50) DEFAULT NULL, - `glosa` mediumtext DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `comentario`; -CREATE TABLE `comentario` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `venta` int(10) unsigned DEFAULT NULL, - `fecha` datetime DEFAULT NULL, - `texto` blob DEFAULT NULL, - `estado` int(11) DEFAULT 1, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `comuna`; -CREATE TABLE `comuna` ( - `id` int(11) unsigned NOT NULL, - `descripcion` varchar(50) NOT NULL, - `provincia` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `fk_provincia` (`provincia`), - CONSTRAINT `comuna_ibfk_1` FOREIGN KEY (`provincia`) REFERENCES `provincia` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `configurations`; -CREATE TABLE `configurations` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(30) NOT NULL, - `value` varchar(255) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `costo`; -CREATE TABLE `costo` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `proyecto` int(11) DEFAULT NULL, - `tipo` int(11) DEFAULT NULL, - `valor` float DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `credito`; -CREATE TABLE `credito` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `banco` varchar(50) DEFAULT NULL, - `valor` float DEFAULT NULL, - `fecha` date DEFAULT NULL, - `uf` float DEFAULT NULL, - `abonado` int(1) DEFAULT 0, - `fecha_abono` date DEFAULT NULL, - `pago` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `cuenta`; -CREATE TABLE `cuenta` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `inmobiliaria` int(8) unsigned NOT NULL, - `banco` int(10) unsigned NOT NULL, - `cuenta` varchar(50) NOT NULL, - PRIMARY KEY (`id`), - KEY `inmobiliaria` (`inmobiliaria`), - KEY `banco` (`banco`), - CONSTRAINT `cuenta_ibfk_1` FOREIGN KEY (`inmobiliaria`) REFERENCES `inmobiliaria` (`rut`) ON DELETE NO ACTION, - CONSTRAINT `cuenta_ibfk_2` FOREIGN KEY (`banco`) REFERENCES `banco` (`id`) ON DELETE NO ACTION -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `cuota`; -CREATE TABLE `cuota` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `pie` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - `valor_$` int(10) unsigned NOT NULL, - `estado` tinyint(1) DEFAULT 0, - `banco` varchar(20) NOT NULL, - `fecha_pago` date DEFAULT NULL, - `abonado` tinyint(1) DEFAULT 0, - `fecha_abono` date DEFAULT NULL, - `uf` double DEFAULT 0, - `pago` int(10) unsigned DEFAULT NULL, - `numero` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `fk_pago_cuota` (`pago`), - KEY `pie` (`pie`), - CONSTRAINT `cuota_ibfk_1` FOREIGN KEY (`pago`) REFERENCES `pago` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `cuota_ibfk_2` FOREIGN KEY (`pie`) REFERENCES `pie` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `depositos`; -CREATE TABLE `depositos` ( - `id` int(10) unsigned NOT NULL, - `cuenta_id` int(10) unsigned NOT NULL, - `capital` int(10) unsigned NOT NULL, - `futuro` int(10) unsigned NOT NULL, - `inicio` date NOT NULL, - `termino` date NOT NULL, - PRIMARY KEY (`id`), - KEY `cuenta_id` (`cuenta_id`), - CONSTRAINT `depositos_ibfk_2` FOREIGN KEY (`cuenta_id`) REFERENCES `cuenta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `direccion`; -CREATE TABLE `direccion` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `calle` varchar(255) NOT NULL, - `numero` int(10) unsigned NOT NULL, - `extra` varchar(255) NOT NULL, - `comuna` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `fk_comuna` (`comuna`), - CONSTRAINT `direccion_ibfk_1` FOREIGN KEY (`comuna`) REFERENCES `comuna` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `entrega`; -CREATE TABLE `entrega` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `fecha` date NOT NULL, - `fondo_operacion` int(11) DEFAULT 0, - `fondo_reserva` int(11) DEFAULT 0, - `fecha_fondo_operacion` date DEFAULT NULL, - `fecha_fondo_reserva` date DEFAULT NULL, - `pago_operacion` int(11) DEFAULT NULL, - `pago_reserva` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `escritura`; -CREATE TABLE `escritura` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `valor` bigint(20) NOT NULL, - `fecha` date NOT NULL, - `uf` float DEFAULT NULL, - `abonado` int(11) DEFAULT 0, - `fecha_abono` date DEFAULT NULL, - `pago` int(11) DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estados_cuentas`; -CREATE TABLE `estados_cuentas` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `cuenta_id` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - `active` tinyint(1) NOT NULL, - PRIMARY KEY (`id`), - KEY `cuenta_id` (`cuenta_id`), - CONSTRAINT `estados_cuentas_ibfk_2` FOREIGN KEY (`cuenta_id`) REFERENCES `cuenta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estado_cierre`; -CREATE TABLE `estado_cierre` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `cierre` int(10) unsigned NOT NULL, - `tipo` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - PRIMARY KEY (`id`), - KEY `cierre` (`cierre`), - KEY `tipo` (`tipo`), - CONSTRAINT `estado_cierre_ibfk_3` FOREIGN KEY (`cierre`) REFERENCES `cierre` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `estado_cierre_ibfk_4` FOREIGN KEY (`tipo`) REFERENCES `tipo_estado_cierre` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estado_cobro`; -CREATE TABLE `estado_cobro` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `cobro` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - `estado` int(11) NOT NULL, - PRIMARY KEY (`id`,`cobro`,`estado`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estado_pago`; -CREATE TABLE `estado_pago` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `pago` int(11) unsigned NOT NULL, - `fecha` date NOT NULL, - `estado` int(11) NOT NULL, - PRIMARY KEY (`id`), - KEY `estado` (`estado`), - CONSTRAINT `estado_pago_ibfk_1` FOREIGN KEY (`estado`) REFERENCES `tipo_estado_pago` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estado_precio`; -CREATE TABLE `estado_precio` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `precio` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - `estado` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `precio` (`precio`), - KEY `estado` (`estado`), - CONSTRAINT `estado_precio_ibfk_3` FOREIGN KEY (`precio`) REFERENCES `precio` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `estado_precio_ibfk_4` FOREIGN KEY (`estado`) REFERENCES `tipo_estado_precio` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estado_problema`; -CREATE TABLE `estado_problema` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `problema` int(11) DEFAULT NULL, - `fecha` date DEFAULT NULL, - `estado` enum('ingreso','revision','correccion','ok') DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estado_proyecto`; -CREATE TABLE `estado_proyecto` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `proyecto` int(10) unsigned NOT NULL, - `estado` int(11) unsigned NOT NULL, - `fecha` date NOT NULL, - PRIMARY KEY (`id`), - KEY `proyecto` (`proyecto`), - KEY `estado` (`estado`), - CONSTRAINT `estado_proyecto_ibfk_1` FOREIGN KEY (`proyecto`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `estado_proyecto_ibfk_3` FOREIGN KEY (`estado`) REFERENCES `tipo_estado_proyecto` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estado_proyecto_agente`; -CREATE TABLE `estado_proyecto_agente` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `agente` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - `tipo` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estado_unidad_bloqueada`; -CREATE TABLE `estado_unidad_bloqueada` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `unidad` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - `tipo` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `estado_venta`; -CREATE TABLE `estado_venta` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `venta` int(10) unsigned NOT NULL, - `estado` int(11) unsigned NOT NULL DEFAULT 1, - `fecha` date NOT NULL, - PRIMARY KEY (`id`), - KEY `escritura` (`venta`), - KEY `estado` (`estado`), - CONSTRAINT `estado_venta_ibfk_1` FOREIGN KEY (`estado`) REFERENCES `tipo_estado_venta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `estado_venta_ibfk_2` FOREIGN KEY (`venta`) REFERENCES `venta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `etapa_proyecto`; -CREATE TABLE `etapa_proyecto` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `descripcion` varchar(20) DEFAULT NULL, - `orden` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `facturas`; -CREATE TABLE `facturas` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `venta_id` int(10) unsigned NOT NULL, - `index` int(10) unsigned NOT NULL, - `proporcion` double unsigned NOT NULL, - `data` text NOT NULL, - PRIMARY KEY (`id`), - KEY `venta_id` (`venta_id`), - CONSTRAINT `facturas_ibfk_2` FOREIGN KEY (`venta_id`) REFERENCES `venta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `factura_proyecto_operador`; -CREATE TABLE `factura_proyecto_operador` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `proyecto_id` int(10) unsigned NOT NULL, - `operador_id` int(10) unsigned NOT NULL, - `factura` int(10) unsigned NOT NULL, - `valor_uf` double unsigned NOT NULL, - `valor_neto` int(10) unsigned NOT NULL, - `iva` int(10) unsigned DEFAULT 0, - PRIMARY KEY (`id`), - KEY `proyecto_id` (`proyecto_id`), - KEY `operador_id` (`operador_id`), - CONSTRAINT `factura_proyecto_operador_ibfk_1` FOREIGN KEY (`proyecto_id`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE, - CONSTRAINT `factura_proyecto_operador_ibfk_2` FOREIGN KEY (`operador_id`) REFERENCES `agente` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `factura_venta`; -CREATE TABLE `factura_venta` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `factura_id` int(10) unsigned NOT NULL, - `venta_id` int(10) unsigned NOT NULL, - `valor` double NOT NULL, - PRIMARY KEY (`id`), - KEY `factura_id` (`factura_id`), - KEY `venta_id` (`venta_id`), - CONSTRAINT `factura_venta_ibfk_1` FOREIGN KEY (`factura_id`) REFERENCES `factura_proyecto_operador` (`id`) ON DELETE CASCADE, - CONSTRAINT `factura_venta_ibfk_2` FOREIGN KEY (`venta_id`) REFERENCES `venta` (`id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `inmobiliaria`; -CREATE TABLE `inmobiliaria` ( - `rut` int(8) unsigned NOT NULL, - `dv` char(1) DEFAULT NULL, - `razon` varchar(255) DEFAULT NULL, - `abreviacion` varchar(50) DEFAULT NULL, - `cuenta` varchar(50) DEFAULT NULL, - `banco` int(11) DEFAULT NULL, - `sociedad` int(10) unsigned DEFAULT NULL, - `sigla` varchar(4) DEFAULT NULL, - PRIMARY KEY (`rut`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `inmobiliarias_nubox`; -CREATE TABLE `inmobiliarias_nubox` ( - `inmobiliaria_rut` int(8) unsigned NOT NULL, - `alias` varchar(100) NOT NULL, - `usuario` varchar(100) NOT NULL, - `contraseƱa` varchar(100) NOT NULL, - KEY `inmobiliaria_rut` (`inmobiliaria_rut`), - CONSTRAINT `inmobiliarias_nubox_ibfk_2` FOREIGN KEY (`inmobiliaria_rut`) REFERENCES `inmobiliaria` (`rut`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `locations`; -CREATE TABLE `locations` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `controller` varchar(50) NOT NULL, - `action` varchar(100) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `logins`; -CREATE TABLE `logins` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `user_id` int(10) unsigned NOT NULL, - `time` datetime NOT NULL, - `selector` varchar(255) NOT NULL, - `token` varchar(255) NOT NULL, - `status` int(1) NOT NULL DEFAULT 1, - PRIMARY KEY (`id`), - KEY `fk_logins_users` (`user_id`), - CONSTRAINT `fk_logins_users` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `monolog`; -CREATE TABLE `monolog` ( - `channel` varchar(255) DEFAULT NULL, - `level` varchar(100) DEFAULT NULL, - `message` longtext DEFAULT NULL, - `time` datetime DEFAULT NULL, - `context` longtext DEFAULT NULL, - `extra` longtext DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `movimientos`; -CREATE TABLE `movimientos` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `cuenta_id` int(10) unsigned NOT NULL, - `fecha` date NOT NULL, - `glosa` text NOT NULL, - `documento` varchar(50) NOT NULL, - `cargo` bigint(20) unsigned NOT NULL DEFAULT 0, - `abono` bigint(20) unsigned NOT NULL DEFAULT 0, - `saldo` bigint(20) NOT NULL DEFAULT 0, - PRIMARY KEY (`id`), - KEY `cuenta_id` (`cuenta_id`), - CONSTRAINT `movimientos_ibfk_2` FOREIGN KEY (`cuenta_id`) REFERENCES `cuenta` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `movimientos_detalles`; -CREATE TABLE `movimientos_detalles` ( - `movimiento_id` int(10) unsigned NOT NULL, - `centro_costo_id` int(10) unsigned DEFAULT NULL, - `categoria` varchar(100) DEFAULT NULL, - `detalle` text DEFAULT NULL, - `rut` int(11) DEFAULT NULL, - `digito` varchar(1) DEFAULT NULL, - `nombres` varchar(255) DEFAULT NULL, - `identificador` varchar(100) DEFAULT NULL, - KEY `movimiento_id` (`movimiento_id`), - KEY `centro_costo_id` (`centro_costo_id`), - CONSTRAINT `movimientos_detalles_ibfk_3` FOREIGN KEY (`movimiento_id`) REFERENCES `movimientos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `movimientos_detalles_ibfk_5` FOREIGN KEY (`centro_costo_id`) REFERENCES `centros_costos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `pagare`; -CREATE TABLE `pagare` ( - `id` int(10) unsigned NOT NULL, - `proyecto` int(10) unsigned NOT NULL, - `moneda` int(10) unsigned NOT NULL, - `capital` double unsigned NOT NULL DEFAULT 0, - `tasa` double unsigned NOT NULL DEFAULT 0, - `fecha` date NOT NULL, - `fecha_banco` date NOT NULL DEFAULT '0000-00-00', - `duracion` int(10) unsigned NOT NULL DEFAULT 0, - `uf` double unsigned NOT NULL DEFAULT 0, - `abonado` int(10) unsigned NOT NULL DEFAULT 0, - `estado_pago` int(10) unsigned NOT NULL DEFAULT 99999999, - PRIMARY KEY (`id`), - KEY `moneda` (`moneda`), - KEY `proyecto` (`proyecto`), - CONSTRAINT `pagare_ibfk_1` FOREIGN KEY (`moneda`) REFERENCES `tipo_moneda_pagare` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `pagare_ibfk_2` FOREIGN KEY (`proyecto`) REFERENCES `proyecto` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `pago`; -CREATE TABLE `pago` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `valor` double NOT NULL, - `banco` int(11) DEFAULT NULL, - `tipo` int(11) DEFAULT NULL, - `identificador` varchar(50) DEFAULT NULL, - `fecha` date DEFAULT NULL, - `uf` double DEFAULT NULL, - `pagador` varchar(50) DEFAULT NULL, - `asociado` int(10) unsigned DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `pagos_centros_costos`; -CREATE TABLE `pagos_centros_costos` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `pago_id` int(11) unsigned NOT NULL, - `centro_costo_id` int(10) unsigned NOT NULL, - PRIMARY KEY (`id`), - KEY `pago_id` (`pago_id`), - KEY `centro_costo_id` (`centro_costo_id`), - CONSTRAINT `pagos_centros_costos_ibfk_3` FOREIGN KEY (`pago_id`) REFERENCES `pago` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `pagos_centros_costos_ibfk_4` FOREIGN KEY (`centro_costo_id`) REFERENCES `centros_costos` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `permissions`; -CREATE TABLE `permissions` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `type` int(1) unsigned NOT NULL, - `ext_id` int(10) unsigned NOT NULL, - `action_id` int(10) unsigned NOT NULL, - `status` int(1) unsigned NOT NULL DEFAULT 1, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `phinxlog`; -CREATE TABLE `phinxlog` ( - `version` bigint(20) NOT NULL, - `migration_name` varchar(100) DEFAULT NULL, - `start_time` timestamp NULL DEFAULT NULL, - `end_time` timestamp NULL DEFAULT NULL, - `breakpoint` tinyint(1) NOT NULL DEFAULT 0, - PRIMARY KEY (`version`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `pie`; -CREATE TABLE `pie` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `fecha` date NOT NULL, - `valor` double unsigned NOT NULL, - `uf` double unsigned DEFAULT NULL, - `cuotas` int(10) unsigned NOT NULL, - `asociado` int(11) DEFAULT 0, - `reajuste` int(11) unsigned DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `precio`; -CREATE TABLE `precio` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `unidad` int(10) unsigned NOT NULL, - `valor` double NOT NULL, - PRIMARY KEY (`id`), - KEY `unidad` (`unidad`), - CONSTRAINT `precio_ibfk_2` FOREIGN KEY (`unidad`) REFERENCES `unidad` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - -DROP TABLE IF EXISTS `problema`; -CREATE TABLE `problema` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `venta` int(11) DEFAULT NULL, - `descripcion` mediumtext DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; - - --- 2024-11-12 15:11:54