feature/migrations #5
@ -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",
|
||||
|
730
app/generate-migrations.php
Normal file
730
app/generate-migrations.php
Normal file
@ -0,0 +1,730 @@
|
||||
<?php
|
||||
require_once implode(DIRECTORY_SEPARATOR, [__DIR__, 'vendor', 'autoload.php']);
|
||||
|
||||
class TableRepository
|
||||
{
|
||||
public function __construct(protected Incoviba\Common\Define\Connection $connection, protected string $database) {}
|
||||
|
||||
public function getTables(): array
|
||||
{
|
||||
if (!isset($this->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 "<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
";
|
||||
}
|
||||
protected function buildClass(string $table): string
|
||||
{
|
||||
return "class {$this->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 "<?php
|
||||
|
||||
use Phinx\Seed\AbstractSeed;
|
||||
";
|
||||
}
|
||||
protected function buildClass(string $table): string
|
||||
{
|
||||
return "class {$this->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);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateAction extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('action')
|
||||
->addColumn('description', 'string', ['length' => 50, 'null' => false])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateAgente extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateAgenteTipo extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateAvanceConstruccion extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateBackup extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('backup')
|
||||
->addColumn('date', 'datetime', ['default' => null, 'null' => true])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateBanco extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('banco')
|
||||
->addColumn('nombre', 'string', ['length' => 20, 'default' => null, 'null' => true])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateBonoPie extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCartolas extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCategoriasCentrosCostos extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('categorias_centros_costos')
|
||||
->addColumn('descripcion', 'string', ['length' => 255, 'null' => false])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCentrosCostos extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCierre extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCobro extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateComentario extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateComuna extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateConfigurations extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCosto extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCredito extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCuenta extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateCuota extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateDepositos extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateDireccion extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEntrega extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEscritura extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadoCierre extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadoCobro extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadoPago extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadoPrecio extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadoProblema extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadoProyecto extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadoProyectoAgente extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadoUnidadBloqueada extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadoVenta extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEstadosCuentas extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateEtapaProyecto extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateFacturaProyectoOperador extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateFacturaVenta extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateFacturas extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateInmobiliaria extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateInmobiliariasNubox extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateLocations extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateLogins extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateMovimientos extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateMovimientosDetalles extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePagare extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePago extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePagosCentrosCostos extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePermissions extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePie extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePrecio extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateProblema extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePromocion extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePromocionVenta extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePropiedad extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePropiedadUnidad extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreatePropietario extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('propietario', ['id' => '`rut`'])
|
||||
->addColumn('rut', 'integer', ['length' => 10, 'null' => false, 'signed' => false])
|
||||
->addColumn('dv', 'char', ['length' => 1, 'null' => false])
|
||||
->addColumn('nombres', 'string', ['length' => 255, 'null' => false])
|
||||
->addColumn('apellido_paterno', 'string', ['length' => 50, 'null' => false])
|
||||
->addColumn('apellido_materno', 'string', ['length' => 50, 'null' => false])
|
||||
->addColumn('sexo', 'string', ['length' => 1, 'default' => null, 'null' => true])
|
||||
->addColumn('estado_civil', 'string', ['length' => 50, 'default' => null, 'null' => true])
|
||||
->addColumn('profesion', 'string', ['length' => 100, 'default' => null, 'null' => true])
|
||||
->addColumn('direccion', 'integer', ['length' => 10, 'default' => 0, 'null' => false, 'signed' => false])
|
||||
->addColumn('telefono', 'integer', ['length' => 10, 'default' => 0, 'signed' => false])
|
||||
->addColumn('email', 'string', ['length' => 100, 'default' => null, 'null' => true])
|
||||
->addColumn('representante', 'integer', ['length' => 10, 'default' => 0])
|
||||
->addColumn('otro', 'integer', ['length' => 11, 'default' => 0])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateProvincia extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateProyectista extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateProyectistas extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateProyecto extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateProyectoAgente extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateProyectoTerreno extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateProyectoTipoUnidad extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateRegion extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateRegistries extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateRegistryData extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateRelacionAgentes extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateRelacionInmobiliarias extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateRemoteIp extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateRenovacionPagare extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateRoles extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateSubsidio extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoAgente extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoCobro extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoElemento extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoEstadoCierre extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoEstadoCobro extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipo_estado_cobro')
|
||||
->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoEstadoPago extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoEstadoPrecio extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipo_estado_precio')
|
||||
->addColumn('descripcion', 'string', ['length' => 50, 'null' => false])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoEstadoProyecto extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoEstadoProyectoAgente extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipo_estado_proyecto_agente')
|
||||
->addColumn('descripcion', 'string', ['length' => 255, 'null' => false])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoEstadoUnidadBloqueada extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoEstadoVenta extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoMonedaPagare extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipo_moneda_pagare')
|
||||
->addColumn('descripcion', 'string', ['length' => 50, 'null' => false])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoPago extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipo_pago')
|
||||
->addColumn('descripcion', 'string', ['length' => 50, 'default' => null, 'null' => true])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoProyectista extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipo_proyectista')
|
||||
->addColumn('descripcion', 'string', ['length' => 20, 'default' => null, 'null' => true])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoSociedad extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoTipologia extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoUnidad extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipoValorCierre extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipo_valor_cierre')
|
||||
->addColumn('descripcion', 'string', ['length' => 50, 'null' => false])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTipologia extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipologia')
|
||||
->addColumn('descripcion', 'string', ['length' => 50, 'null' => false])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTiposCentrosCostos extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipos_centros_costos')
|
||||
->addColumn('descripcion', 'string', ['length' => 50, 'null' => false])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateTiposCuentasCostos extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('tipos_cuentas_costos')
|
||||
->addColumn('descripcion', 'string', ['length' => 50, 'null' => false])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateUf extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateUnidad extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateUnidadBloqueada extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateUnidadCierre extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateUnidadProrrateo extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateUserRoles extends Phinx\Migration\AbstractMigration
|
||||
{
|
||||
public function change(): void
|
||||
{
|
||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||
$this->execute("ALTER DATABASE CHARACTER SET 'utf8mb4';");
|
||||
$this->execute("ALTER DATABASE COLLATE='utf8mb4_general_ci';");
|
||||
|
||||
$this->table('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;');
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user