Compare commits
5 Commits
13b246b998
...
master
Author | SHA1 | Date | |
---|---|---|---|
6ddc48ec60 | |||
331ee1e584 | |||
24c17debf3 | |||
552fd0aa06 | |||
60faf293d4 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,5 +10,3 @@
|
||||
**/.idea/
|
||||
**/upload?/
|
||||
**/informe?/
|
||||
**/.phpunit.cache/
|
||||
**/coverage/
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM php:8.4-cli
|
||||
FROM php:8.2-cli
|
||||
|
||||
ENV TZ "${TZ}"
|
||||
ENV APP_NAME "${APP_NAME}"
|
||||
@ -6,14 +6,11 @@ ENV API_URL "${API_URL}"
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cron rsyslog nano && rm -r /var/lib/apt/lists/*
|
||||
|
||||
RUN pecl install xdebug-3.4.2 \
|
||||
RUN pecl install xdebug-3.2.2 \
|
||||
&& docker-php-ext-enable xdebug \
|
||||
&& echo $TZ > /etc/timezone
|
||||
|
||||
COPY --chmod=550 ./cli/entrypoint /root/entrypoint
|
||||
&& echo "#/bin/bash\nprintenv >> /etc/environment\ncron -f -L 11" > /root/entrypoint && chmod a+x /root/entrypoint
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
COPY ./php-timezone.ini /usr/local/etc/php/conf.d/docker-php-timezone.ini
|
||||
|
||||
WORKDIR /code/bin
|
||||
|
||||
|
19
Dockerfile
19
Dockerfile
@ -1,19 +1,14 @@
|
||||
FROM php:8.4-fpm
|
||||
FROM php:8.1-fpm
|
||||
|
||||
ENV TZ=America/Santiago
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git libpng-dev unzip tzdata \
|
||||
&& rm -r /var/lib/apt/lists/*
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends libzip-dev libicu-dev git \
|
||||
libpng-dev unzip tzdata libxml2-dev \
|
||||
&& rm -r /var/lib/apt/lists/* \
|
||||
&& docker-php-ext-install pdo pdo_mysql zip intl gd bcmath dom \
|
||||
&& pecl install xdebug-3.4.2 \
|
||||
&& docker-php-ext-enable xdebug \
|
||||
&& echo $TZ > /etc/timezone
|
||||
RUN docker-php-ext-install pdo pdo_mysql zip intl gd bcmath
|
||||
|
||||
RUN pecl install xdebug-3.1.3 \
|
||||
&& docker-php-ext-enable xdebug
|
||||
|
||||
COPY ./php-errors.ini /usr/local/etc/php/conf.d/docker-php-errors.ini
|
||||
COPY ./php-xdebug.ini /usr/local/etc/php/conf.d/docker-php-xdebug.ini
|
||||
COPY ./php-memory.ini /usr/local/etc/php/conf.d/docker-php-memory.ini
|
||||
COPY ./php-timezone.ini /usr/local/etc/php/conf.d/docker-php-timezone.ini
|
||||
|
||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
services:
|
||||
httpclient:
|
||||
profiles:
|
||||
- testing
|
||||
container_name: incoviba_client
|
||||
image: flawiddsouza/restfox
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${HTTPCLIENT_PORT:-4004}:4004"
|
@ -1,19 +1,11 @@
|
||||
#ENVIRONMENT=
|
||||
|
||||
APP_URL=
|
||||
|
||||
MYSQL_HOST=db
|
||||
|
||||
COOKIE_NAME=
|
||||
COOKIE_DOMAIN=
|
||||
COOKIE_PATH=/
|
||||
MAX_LOGIN_HOURS=120
|
||||
|
||||
#REDIS_HOST=redis
|
||||
#REDIS_PORT=6379
|
||||
|
||||
DB_HOST=db
|
||||
DB_DATABASE=incoviba
|
||||
DB_USER=incoviba
|
||||
DB_PASSWORD=
|
||||
|
||||
TOKU_URL=
|
||||
TOKU_TOKEN=
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
|
2
app/.gitignore
vendored
2
app/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
**/bin
|
||||
**/public/tests
|
@ -1,14 +0,0 @@
|
||||
watch:
|
||||
directories:
|
||||
- src
|
||||
- tests
|
||||
- common
|
||||
- resources
|
||||
fileMask: '*.php'
|
||||
notifications:
|
||||
passingTests: false
|
||||
failingTests: false
|
||||
hideManual: true
|
||||
phpunit:
|
||||
arguments: '--testsuite unit --log-events-text /logs/output.txt --stop-on-failure'
|
||||
timeout: 180
|
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
php -d auto_prepend_file=test.bootstrap.php -a
|
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
bin/phpunit --testsuite acceptance $@
|
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
bin/phpunit --testsuite performance $@
|
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
./bin/phpunit --testsuite unit $@
|
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Alias;
|
||||
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Slim\Views\Blade;
|
||||
|
||||
class View extends Blade {}
|
||||
class View extends Blade
|
||||
{
|
||||
}
|
||||
|
@ -5,11 +5,6 @@ use Psr\Http\Message\UploadedFileInterface;
|
||||
|
||||
interface Banco
|
||||
{
|
||||
/**
|
||||
* Process bank movements for database inserts
|
||||
* @param UploadedFileInterface $file
|
||||
* @return array
|
||||
*/
|
||||
public function process(UploadedFileInterface $file): array;
|
||||
|
||||
}
|
||||
|
@ -3,42 +3,13 @@ namespace Incoviba\Common\Define;
|
||||
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use PDOException;
|
||||
|
||||
interface Connection
|
||||
{
|
||||
/**
|
||||
* @return Connection
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function connect(): Connection;
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @return PDOStatement
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function query(string $query): PDOStatement;
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @return PDOStatement
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function prepare(string $query): PDOStatement;
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array|null $data
|
||||
* @return PDOStatement
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function execute(string $query, ?array $data = null): PDOStatement;
|
||||
|
||||
/**
|
||||
* @return PDO
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function getPDO(): PDO;
|
||||
public function getQueryBuilder(): Query\Builder;
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ use Incoviba\Model;
|
||||
|
||||
interface Exporter
|
||||
{
|
||||
public function export(Model\Inmobiliaria $inmobiliaria, Model\Contabilidad\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||
public function export(Model\Inmobiliaria $inmobiliaria, Model\Banco $banco, DateTimeInterface $mes, array $movimientos): string;
|
||||
}
|
||||
|
@ -2,15 +2,8 @@
|
||||
namespace Incoviba\Common\Define\Money;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResponse;
|
||||
|
||||
interface Provider
|
||||
{
|
||||
/**
|
||||
* @param string $money_symbol
|
||||
* @param ?DateTimeInterface $dateTime = null
|
||||
* @return float
|
||||
* @throws EmptyResponse
|
||||
*/
|
||||
public function get(string $money_symbol, ?DateTimeInterface $dateTime = null): float;
|
||||
public function get(string $money_symbol, DateTimeInterface $dateTime): float;
|
||||
}
|
||||
|
@ -1,42 +1,11 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Define;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use PDOException;
|
||||
|
||||
interface Repository
|
||||
{
|
||||
/**
|
||||
* @param array|null $data
|
||||
* @return Model
|
||||
*/
|
||||
public function create(?array $data = null): Model;
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return Model
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function save(Model $model): Model;
|
||||
|
||||
/**
|
||||
* @param array $data_row
|
||||
* @return Model
|
||||
*/
|
||||
public function load(array $data_row): Model;
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @param array $new_data
|
||||
* @return Model
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
public function edit(Model $model, array $new_data): Model;
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
* @return void
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function remove(Model $model): void;
|
||||
}
|
||||
|
@ -9,55 +9,9 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
||||
{
|
||||
public function process(UploadedFileInterface $file): array
|
||||
{
|
||||
$filename = $this->processUploadedFile($file);
|
||||
$data = $this->processFile($filename);
|
||||
return $this->mapColumns($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* There are banks that need some post-processing
|
||||
* @param array $movimientos
|
||||
* @return array
|
||||
*/
|
||||
public function processMovimientosDiarios(array $movimientos): array
|
||||
{
|
||||
return $movimientos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move the UploadedFile into a temp file from getFilename
|
||||
* @param UploadedFileInterface $uploadedFile
|
||||
* @return string
|
||||
*/
|
||||
protected function processUploadedFile(UploadedFileInterface $uploadedFile): string
|
||||
{
|
||||
$filename = $this->getFilename($uploadedFile);
|
||||
$uploadedFile->moveTo($filename);
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the temp file from getFilename and remove it
|
||||
* @param string $filename
|
||||
* @return array
|
||||
*/
|
||||
protected function processFile(string $filename): array
|
||||
{
|
||||
$data = $this->parseFile($filename);
|
||||
unlink($filename);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map columns from uploaded file data to database columns
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function mapColumns(array $data): array
|
||||
{
|
||||
$data = $this->parseFile($file);
|
||||
$temp = [];
|
||||
$columns = $this->columnMap();
|
||||
|
||||
foreach ($data as $row) {
|
||||
$r = [];
|
||||
foreach ($columns as $old => $new) {
|
||||
@ -70,24 +24,11 @@ abstract class Banco extends Service implements Define\Cartola\Banco
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
public function processMovimientosDiarios(array $movimientos): array
|
||||
{
|
||||
return $movimientos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filename where to move UploadedFile
|
||||
* @param UploadedFileInterface $uploadedFile
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getFilename(UploadedFileInterface $uploadedFile): string;
|
||||
|
||||
/**
|
||||
* Mapping of uploaded file data columns to database columns
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function columnMap(): array;
|
||||
|
||||
/**
|
||||
* Translate uploaded file data to database data
|
||||
* @param string $filename
|
||||
* @return array
|
||||
*/
|
||||
abstract protected function parseFile(string $filename): array;
|
||||
abstract protected function parseFile(UploadedFileInterface $uploadedFile): array;
|
||||
}
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Ideal;
|
||||
|
||||
use Psr\Log\LoggerAwareInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class LoggerEnabled implements LoggerAwareInterface
|
||||
{
|
||||
protected LoggerInterface $logger;
|
||||
public function setLogger(LoggerInterface $logger): void
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
public function getLogger(): LoggerInterface
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
}
|
@ -26,13 +26,7 @@ abstract class Model implements Define\Model
|
||||
public function jsonSerialize(): mixed
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
...$this->jsonComplement()
|
||||
'id' => $this->id
|
||||
];
|
||||
}
|
||||
|
||||
protected function jsonComplement(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,7 @@
|
||||
namespace Incoviba\Common\Ideal;
|
||||
|
||||
use PDO;
|
||||
use PDOException;
|
||||
use ReflectionProperty;
|
||||
use ReflectionException;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
@ -24,15 +22,10 @@ abstract class Repository implements Define\Repository
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getConnection(): Define\Connection
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
public function load(array $data_row): Define\Model
|
||||
{
|
||||
$model = $this->create($data_row);
|
||||
$this->setIndex($model, $data_row[$this->getKey()]);
|
||||
$model->{$this->getKey()} = $data_row[$this->getKey()];
|
||||
return $model;
|
||||
}
|
||||
|
||||
@ -41,12 +34,9 @@ abstract class Repository implements Define\Repository
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->delete()->from($this->getTable())
|
||||
->where("{$this->getKey()} = ?");
|
||||
$this->connection->execute($query, [$this->getIndex($model)]);
|
||||
$this->connection->execute($query, [$model->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
public function fetchById(int $id): Define\Model
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -55,10 +45,6 @@ abstract class Repository implements Define\Repository
|
||||
->where("{$this->getKey()} = ?");
|
||||
return $this->fetchOne($query, [$id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
public function fetchAll(null|string|array $ordering = null): array
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -70,27 +56,10 @@ abstract class Repository implements Define\Repository
|
||||
return $this->fetchMany($query);
|
||||
}
|
||||
|
||||
protected string $key = 'id';
|
||||
public function setKey(string $key): Repository
|
||||
{
|
||||
$this->key = $key;
|
||||
return $this;
|
||||
}
|
||||
protected function getKey(): string
|
||||
{
|
||||
return $this->key;
|
||||
return 'id';
|
||||
}
|
||||
|
||||
protected function setIndex(Define\Model &$model, mixed $value): Repository
|
||||
{
|
||||
$model->{$this->getKey()} = $value;
|
||||
return $this;
|
||||
}
|
||||
protected function getIndex(Define\Model $model): mixed
|
||||
{
|
||||
return $model->id;
|
||||
}
|
||||
|
||||
protected function parseData(Define\Model $model, ?array $data, Implement\Repository\MapperParser $data_map): Define\Model
|
||||
{
|
||||
if ($data === null) {
|
||||
@ -123,20 +92,9 @@ abstract class Repository implements Define\Repository
|
||||
}
|
||||
$this->setDefault($model, $property);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Define\Model $model
|
||||
* @param string $property
|
||||
* @return void
|
||||
*/
|
||||
protected function setDefault(Define\Model &$model, string $property): void
|
||||
{
|
||||
try {
|
||||
$prop = new ReflectionProperty($model, $property);
|
||||
} catch (ReflectionException) {
|
||||
$model->{$property} = null;
|
||||
return;
|
||||
}
|
||||
$prop = new ReflectionProperty($model, $property);
|
||||
$type = $prop->getType()->getName();
|
||||
$value = match ($type) {
|
||||
'int' => 0,
|
||||
@ -146,13 +104,6 @@ abstract class Repository implements Define\Repository
|
||||
};
|
||||
$model->{$property} = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $columns
|
||||
* @param array $values
|
||||
* @return int
|
||||
* @throws PDOException
|
||||
*/
|
||||
protected function saveNew(array $columns, array $values): int
|
||||
{
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
@ -163,14 +114,6 @@ abstract class Repository implements Define\Repository
|
||||
$this->connection->execute($query, $values);
|
||||
return $this->connection->getPDO()->lastInsertId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Define\Model $model
|
||||
* @param array $columns
|
||||
* @param array $data
|
||||
* @return Define\Model
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
protected function update(Define\Model $model, array $columns, array $data): Define\Model
|
||||
{
|
||||
$changes = [];
|
||||
@ -190,68 +133,32 @@ abstract class Repository implements Define\Repository
|
||||
->update($this->getTable())
|
||||
->set($columns_string)
|
||||
->where("{$this->getKey()} = ?");
|
||||
$values []= $this->getIndex($model);
|
||||
try {
|
||||
$this->connection->execute($query, $values);
|
||||
} catch (PDOException $exception) {
|
||||
throw new EmptyResult($query, $exception, $data);
|
||||
}
|
||||
return $this->fetchById($this->getIndex($model));
|
||||
$values []= $model->{$this->getKey()};
|
||||
$this->connection->execute($query, $values);
|
||||
return $this->fetchById($model->{$this->getKey()});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array|null $data
|
||||
* @return Define\Model
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
protected function fetchOne(string $query, ?array $data = null): Define\Model
|
||||
{
|
||||
try {
|
||||
$result = $this->connection->execute($query, $data)->fetch(PDO::FETCH_ASSOC);
|
||||
if ($result === false) {
|
||||
throw new EmptyResult($query, null, $data);
|
||||
}
|
||||
} catch (PDOException $exception) {
|
||||
throw new EmptyResult($query, $exception, $data);
|
||||
$result = $this->connection->execute($query, $data)->fetch(PDO::FETCH_ASSOC);
|
||||
if ($result === false) {
|
||||
throw new EmptyResult($query);
|
||||
}
|
||||
return $this->load($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array|null $data
|
||||
* @return array
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
protected function fetchMany(string $query, ?array $data = null): array
|
||||
{
|
||||
try {
|
||||
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $exception) {
|
||||
throw new EmptyResult($query, $exception, $data);
|
||||
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($results === false) {
|
||||
throw new EmptyResult($query);
|
||||
}
|
||||
return array_map([$this, 'load'], $results);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array|null $data
|
||||
* @return array
|
||||
* @throws EmptyResult
|
||||
*/
|
||||
protected function fetchAsArray(string $query, ?array $data = null): array
|
||||
{
|
||||
try {
|
||||
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $exception) {
|
||||
throw new EmptyResult($query, $exception, $data);
|
||||
$results = $this->connection->execute($query, $data)->fetchAll(PDO::FETCH_ASSOC);
|
||||
if ($results === false) {
|
||||
throw new EmptyResult($query);
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function filterData(array $data): array
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -1,56 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Ideal\Service;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Exception\ServiceAction;
|
||||
|
||||
abstract class API extends Ideal\Service
|
||||
{
|
||||
public function __construct(LoggerInterface $logger)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|array|null $order
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getAll(null|string|array $order = null): array;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Define\Model
|
||||
* @throws ServiceAction\Read
|
||||
*/
|
||||
abstract public function get(int $id): Define\Model;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return Define\Model
|
||||
* @throws ServiceAction\Create
|
||||
*/
|
||||
abstract public function add(array $data): Define\Model;
|
||||
|
||||
/**
|
||||
* @param Define\Model $model
|
||||
* @param array $new_data
|
||||
* @return Define\Model
|
||||
* @throws ServiceAction\Update
|
||||
*/
|
||||
abstract public function edit(Define\Model $model, array $new_data): Define\Model;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Define\Model
|
||||
* @throws ServiceAction\Delete
|
||||
*/
|
||||
abstract public function delete(int $id): Define\Model;
|
||||
|
||||
/**
|
||||
* @param Define\Model $model
|
||||
* @return Define\Model
|
||||
*/
|
||||
abstract protected function process(Define\Model $model): Define\Model;
|
||||
}
|
@ -22,7 +22,6 @@ class Connection implements Define\Connection
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPDO(): PDO
|
||||
{
|
||||
$this->connect();
|
||||
|
@ -81,9 +81,6 @@ class Insert extends Ideal\Query implements Define\Query\Insert
|
||||
if ($value === (int) $value) {
|
||||
return $value;
|
||||
}
|
||||
if (str_starts_with($value, ':')) {
|
||||
return $value;
|
||||
}
|
||||
return "'{$value}'";
|
||||
}, $this->values)) . ')';
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ class Select extends Ideal\Query implements Define\Query\Select
|
||||
}
|
||||
protected function addCondition(string $condition): Select
|
||||
{
|
||||
if (!isset($this->conditions)) {
|
||||
if (!isset($this->coditions)) {
|
||||
$this->conditions = [];
|
||||
}
|
||||
$this->conditions []= $condition;
|
||||
|
@ -6,15 +6,10 @@ use Throwable;
|
||||
|
||||
class EmptyResult extends Exception
|
||||
{
|
||||
public function __construct(public string $query, ?Throwable $previous = null, protected ?array $data = null)
|
||||
public function __construct(string $query, ?Throwable $previous = null)
|
||||
{
|
||||
$message = "Empty results for {$query}";
|
||||
$code = 700;
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
|
||||
public function getData(): ?array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Exception;
|
||||
|
||||
use Throwable;
|
||||
use Exception;
|
||||
|
||||
class HttpResponse extends Exception
|
||||
{
|
||||
public function __construct($reason = "", $message = "", $code = 0, Throwable $previous = null)
|
||||
{
|
||||
$this->reason = "HTTP Reason: {$reason}";
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
protected string $reason;
|
||||
public function getReason(): string
|
||||
{
|
||||
return $this->reason;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Log\Formatter;
|
||||
|
||||
use Monolog\Formatter\JsonFormatter;
|
||||
use Monolog\LogRecord;
|
||||
|
||||
class PDO extends JsonFormatter
|
||||
{
|
||||
public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = true)
|
||||
{
|
||||
parent::__construct($batchMode, $appendNewline, $ignoreEmptyContextAndExtra, $includeStacktraces);
|
||||
}
|
||||
|
||||
public function format(LogRecord $record): string
|
||||
{
|
||||
$normalized = $this->normalize($record, $this->maxNormalizeDepth);
|
||||
return $normalized['message'];
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Log\Handler;
|
||||
|
||||
use Incoviba\Common\Define\Connection;
|
||||
use Monolog\Handler\AbstractProcessingHandler;
|
||||
use Monolog\Level;
|
||||
use Monolog\LogRecord;
|
||||
use PDOStatement;
|
||||
|
||||
class MySQL extends AbstractProcessingHandler
|
||||
{
|
||||
private bool $initialized = false;
|
||||
private PDOStatement $statement;
|
||||
|
||||
public function __construct(protected Connection $connection, protected int $retainDays = 90, int|string|Level $level = Level::Debug, bool $bubble = true)
|
||||
{
|
||||
parent::__construct($level, $bubble);
|
||||
}
|
||||
public function write(LogRecord $record): void
|
||||
{
|
||||
if (!$this->initialized) {
|
||||
if (!$this->checkTableExists()) {
|
||||
$this->createTable();
|
||||
}
|
||||
$this->cleanup();
|
||||
$this->initialized();
|
||||
}
|
||||
$this->statement->execute([
|
||||
'channel' => $record->channel,
|
||||
'level' => $record->level->getName(),
|
||||
'message' => $record->formatted,
|
||||
'time' => $record->datetime->format('Y-m-d H:i:s.u'),
|
||||
'context' => (count($record->context) > 0) ? json_encode($record->context, JSON_UNESCAPED_SLASHES) : '',
|
||||
'extra' => (count($record->extra) > 0) ? json_encode($record->extra, JSON_UNESCAPED_SLASHES) : ''
|
||||
]);
|
||||
}
|
||||
|
||||
private function initialized(): void
|
||||
{
|
||||
$query = <<<QUERY
|
||||
INSERT INTO monolog (channel, level, message, time, context, extra)
|
||||
VALUES (:channel, :level, :message, :time, :context, :extra)
|
||||
QUERY;
|
||||
$this->statement = $this->connection->getPDO()->prepare($query);
|
||||
$this->initialized = true;
|
||||
}
|
||||
private function checkTableExists(): bool
|
||||
{
|
||||
$query = "SHOW TABLES LIKE 'monolog'";
|
||||
$result = $this->connection->query($query);
|
||||
return $result->rowCount() > 0;
|
||||
}
|
||||
private function createTable(): void
|
||||
{
|
||||
$query = <<<QUERY
|
||||
CREATE TABLE IF NOT EXISTS monolog (
|
||||
channel VARCHAR(255),
|
||||
level VARCHAR(100),
|
||||
message LONGTEXT,
|
||||
time DATETIME,
|
||||
context LONGTEXT,
|
||||
extra LONGTEXT
|
||||
)
|
||||
QUERY;
|
||||
$this->connection->getPDO()->exec($query);
|
||||
}
|
||||
private function cleanup(): void
|
||||
{
|
||||
$query = "DELETE FROM monolog WHERE time < DATE_SUB(CURDATE(), INTERVAL {$this->retainDays} DAY)";
|
||||
$this->connection->query($query);
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Log\Processor;
|
||||
|
||||
use Incoviba\Service;
|
||||
use Monolog\LogRecord;
|
||||
use Monolog\Processor\ProcessorInterface;
|
||||
|
||||
class User implements ProcessorInterface
|
||||
{
|
||||
public function __construct(protected Service\Login $loginService) {}
|
||||
public function __invoke(LogRecord $record): LogRecord
|
||||
{
|
||||
if ($this->loginService->isIn()) {
|
||||
$record->extra['user'] = $this->loginService->getUser()->name;
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
<?php
|
||||
namespace Incoviba\Common\Implement\Repository;
|
||||
|
||||
use Error;
|
||||
use Closure;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
|
||||
class Mapper implements Define\Repository\Mapper
|
||||
{
|
||||
@ -48,11 +46,7 @@ class Mapper implements Define\Repository\Mapper
|
||||
}
|
||||
public function hasDefault(): bool
|
||||
{
|
||||
try {
|
||||
return isset($this->default) or $this->default === null;
|
||||
} catch (Error) {
|
||||
return false;
|
||||
}
|
||||
return isset($this->default);
|
||||
}
|
||||
|
||||
public function parse(Define\Model &$model, string $column, ?array $data): bool
|
||||
@ -68,14 +62,10 @@ class Mapper implements Define\Repository\Mapper
|
||||
}
|
||||
$value = $data[$column];
|
||||
if ($this->hasFunction()) {
|
||||
try {
|
||||
if ($value !== null) {
|
||||
$value = ($this->function)($data);
|
||||
} catch (EmptyResult $exception) {
|
||||
if ($this->hasDefault()) {
|
||||
$value = $this->default;
|
||||
} else {
|
||||
throw $exception;
|
||||
}
|
||||
} elseif ($this->hasDefault()) {
|
||||
$value = $this->default;
|
||||
}
|
||||
}
|
||||
$model->{$property} = $value;
|
||||
|
@ -2,7 +2,6 @@
|
||||
namespace Incoviba\Common\Implement\Repository\Mapper;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use DateMalformedStringException;
|
||||
use Incoviba\Common\Implement\Repository\Mapper;
|
||||
|
||||
class DateTime extends Mapper
|
||||
@ -10,17 +9,7 @@ class DateTime extends Mapper
|
||||
public function __construct(string $column, ?string $property = null)
|
||||
{
|
||||
$this->setFunction(function($data) use ($column) {
|
||||
if (!isset($data[$column])) {
|
||||
return null;
|
||||
}
|
||||
if (is_a($data[$column], DateTimeImmutable::class)) {
|
||||
return $data[$column];
|
||||
}
|
||||
try {
|
||||
return new DateTimeImmutable($data[$column] ?? '');
|
||||
} catch (DateMalformedStringException) {
|
||||
return new DateTimeImmutable();
|
||||
}
|
||||
return new DateTimeImmutable($data[$column] ?? '');
|
||||
});
|
||||
if ($property !== null) {
|
||||
$this->setProperty($property);
|
||||
|
@ -1,33 +1,21 @@
|
||||
{
|
||||
"name": "incoviba/web",
|
||||
"version": "2.0.0",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-openssl": "*",
|
||||
"ext-pdo": "*",
|
||||
"berrnd/slim-blade-view": "^1",
|
||||
"guzzlehttp/guzzle": "^7",
|
||||
"monolog/monolog": "^3",
|
||||
"nyholm/psr7": "^1",
|
||||
"nyholm/psr7-server": "^1",
|
||||
"php-di/php-di": "^7",
|
||||
"php-di/slim-bridge": "^3",
|
||||
"phpoffice/phpspreadsheet": "^3",
|
||||
"predis/predis": "^2",
|
||||
"robmorgan/phinx": "^0.16",
|
||||
"slim/slim": "^4",
|
||||
"symfony/string": "^7.2",
|
||||
"tedivm/jshrink": "^1.7"
|
||||
"berrnd/slim-blade-view": "^1.0",
|
||||
"guzzlehttp/guzzle": "^7.8",
|
||||
"monolog/monolog": "^3.4",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"nyholm/psr7-server": "^1.0",
|
||||
"php-di/php-di": "^7.0",
|
||||
"php-di/slim-bridge": "^3.4",
|
||||
"phpoffice/phpspreadsheet": "^1.29",
|
||||
"predis/predis": "^2.2",
|
||||
"slim/slim": "^4.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1",
|
||||
"kint-php/kint": "^5",
|
||||
"odan/phinx-migrations-generator": "^6",
|
||||
"phpunit/phpunit": "^11",
|
||||
"spatie/phpunit-watcher": "^1"
|
||||
"kint-php/kint": "^5.1",
|
||||
"phpunit/phpunit": "^10.2"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
@ -42,8 +30,6 @@
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"process-timeout": 0,
|
||||
"bin-dir": "bin"
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
|
@ -1,730 +0,0 @@
|
||||
<?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);
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
return
|
||||
[
|
||||
'paths' => [
|
||||
'migrations' => '%%PHINX_CONFIG_DIR%%/resources/database/migrations',
|
||||
'seeds' => '%%PHINX_CONFIG_DIR%%/resources/database/seeds'
|
||||
],
|
||||
'environments' => [
|
||||
'default_migration_table' => 'phinxlog',
|
||||
'default_environment' => 'development',
|
||||
'production' => [
|
||||
'adapter' => 'mysql',
|
||||
'host' => $_ENV['DB_HOST'] ?? 'localhost',
|
||||
'name' => $_ENV['DB_DATABASE'],
|
||||
'user' => $_ENV['DB_USER'],
|
||||
'pass' => $_ENV['DB_PASSWORD'],
|
||||
'port' => '3306',
|
||||
'charset' => 'utf8',
|
||||
],
|
||||
'development' => [
|
||||
'adapter' => 'mysql',
|
||||
'host' => $_ENV['DB_HOST'] ?? 'localhost',
|
||||
'name' => $_ENV['DB_DATABASE'],
|
||||
'user' => $_ENV['DB_USER'],
|
||||
'pass' => $_ENV['DB_PASSWORD'],
|
||||
'port' => '3306',
|
||||
'charset' => 'utf8',
|
||||
],
|
||||
'testing' => [
|
||||
'adapter' => 'mysql',
|
||||
'host' => $_ENV['DB_HOST'] ?? 'localhost',
|
||||
'name' => $_ENV['DB_DATABASE'],
|
||||
'user' => $_ENV['DB_USER'],
|
||||
'pass' => $_ENV['DB_PASSWORD'],
|
||||
'port' => '3306',
|
||||
'charset' => 'utf8',
|
||||
]
|
||||
],
|
||||
'version_order' => 'creation',
|
||||
'schema_file' => '%%PHINX_CONFIG_DIR%%/resources/database/schema.php',
|
||||
'foreign_keys' => true,
|
||||
'generate_migration_name' => true,
|
||||
'default_migration_prefix' => 'incoviba_',
|
||||
'mark_generated_migration' => true
|
||||
];
|
@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
|
||||
bootstrap="test.bootstrap.php"
|
||||
cacheDirectory="/code/cache/tests"
|
||||
executionOrder="depends,defects"
|
||||
requireCoverageMetadata="false"
|
||||
beStrictAboutCoverageMetadata="false"
|
||||
beStrictAboutOutputDuringTests="true"
|
||||
colors="true"
|
||||
failOnRisky="false"
|
||||
failOnWarning="false">
|
||||
<testsuites>
|
||||
<testsuite name="unit">
|
||||
<directory>tests/unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="acceptance">
|
||||
<directory>tests/integration</directory>
|
||||
</testsuite>
|
||||
<testsuite name="performance">
|
||||
<directory>tests/performance</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<source restrictNotices="true" restrictWarnings="true" ignoreIndirectDeprecations="true">
|
||||
<include>
|
||||
<directory>src</directory>
|
||||
<directory>common</directory>
|
||||
</include>
|
||||
</source>
|
||||
<!--<coverage pathCoverage="false" ignoreDeprecatedCodeUnits="true" disableCodeCoverageIgnore="true">
|
||||
<report>
|
||||
<html outputDirectory="/code/public/coverage/html"/>
|
||||
</report>
|
||||
</coverage>-->
|
||||
<logging>
|
||||
<junit outputFile="/code/cache/tests/junit.xml"/>
|
||||
<teamcity outputFile="/code/cache/tests/teamcity.txt"/>
|
||||
<!--<testdoxHtml outputFile="/code/public/tests/testdox.html"/>-->
|
||||
<testdoxText outputFile="/code/cache/tests/testdox.txt"/>
|
||||
</logging>
|
||||
</phpunit>
|
Binary file not shown.
Before Width: | Height: | Size: 894 B |
@ -13,12 +13,3 @@ try {
|
||||
$app->getContainer()->get(Psr\Log\LoggerInterface::class)->notice($exception);
|
||||
header('Location: /construccion');
|
||||
}
|
||||
register_shutdown_function(function() {
|
||||
$error = error_get_last();
|
||||
|
||||
$fatal_errors = [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR];
|
||||
if ($error !== null and in_array($error['type'], $fatal_errors, true)) {
|
||||
error_log(json_encode($error).PHP_EOL,3, '/logs/fatal.log');
|
||||
}
|
||||
error_clear_last();
|
||||
});
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?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', 'text', ['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;');
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?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', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false])
|
||||
->addColumn('abonos', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false])
|
||||
->addColumn('saldo', 'biginteger', ['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;');
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?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', 'text', ['null' => false, 'limit' => MysqlAdapter::TEXT_MEDIUM])
|
||||
->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;');
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?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', 'text', ['default' => null, 'null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?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', 'biginteger', ['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;');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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', ['values' => ['ingreso','revision','correccion','ok'], 'default' => null, 'null' => true])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Phinx\Db\Adapter\MysqlAdapter;
|
||||
|
||||
class CreateVentaDatosFacturas 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('venta_datos_facturas')
|
||||
->addColumn('venta_id', 'integer', ['length' => 10, 'signed' => false])
|
||||
->addColumn('fecha', 'date')
|
||||
->addColumn('uf', 'string', ['length' => 50]) // fecha, valor
|
||||
->addColumn('ipc', 'string', ['length' => 50]) // fecha, valor
|
||||
->addColumn('terreno', 'integer', ['signed' => false])
|
||||
->addColumn('unidades', 'text') // id, precios, prorrateo
|
||||
->addForeignKey('venta_id', 'venta', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?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, 'signed' => false])
|
||||
->addColumn('index', 'integer', ['signed' => false])
|
||||
->addColumn('proporcion', 'double', ['signed' => false]) // %
|
||||
->addColumn('cliente_rut', 'integer', ['length' => 10, 'signed' => false])
|
||||
->addForeignKey('venta_id', 'venta', 'id', ['delete' => 'cascade', 'update' => 'cascade'])
|
||||
->addForeignKey('cliente_rut', 'personas', 'rut', ['delete' => 'cascade', 'update' => 'cascade'])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?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', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false])
|
||||
->addColumn('abono', 'biginteger', ['length' => 20, 'default' => 0, 'null' => false, 'signed' => false])
|
||||
->addColumn('saldo', 'biginteger', ['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;');
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?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', 'text', ['default' => null, 'null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM])
|
||||
->create();
|
||||
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
<?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', 'text', ['null' => false, 'limit' => MysqlAdapter::TEXT_MEDIUM])
|
||||
->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;');
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?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;');
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?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', 'text', ['default' => null, 'null' => true, 'limit' => MysqlAdapter::TEXT_MEDIUM])
|
||||
->addForeignKey('proyecto', 'proyecto', '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