diff --git a/modules/addons/NFEioServiceInvoices/lib/Migrations/Migrations.php b/modules/addons/NFEioServiceInvoices/lib/Migrations/Migrations.php index b81d212..726605a 100644 --- a/modules/addons/NFEioServiceInvoices/lib/Migrations/Migrations.php +++ b/modules/addons/NFEioServiceInvoices/lib/Migrations/Migrations.php @@ -234,7 +234,7 @@ public static function migrateTimestampColumns(string $tableName) $pdo = Capsule::connection()->getPdo(); $pdo->beginTransaction(); try { - $self = new static(); + $self = new self(); $self->createAlterColumnTimestampStatement($pdo, 'created_at', 'CURRENT_TIMESTAMP', $tableName); $self->createAlterColumnTimestampStatement($pdo, 'updated_at', 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', $tableName); if ($pdo->inTransaction()) { diff --git a/modules/addons/NFEioServiceInvoices/lib/Models/Aliquots/Repository.php b/modules/addons/NFEioServiceInvoices/lib/Models/Aliquots/Repository.php index 5dd11d3..d39ceea 100644 --- a/modules/addons/NFEioServiceInvoices/lib/Models/Aliquots/Repository.php +++ b/modules/addons/NFEioServiceInvoices/lib/Models/Aliquots/Repository.php @@ -81,8 +81,11 @@ public function drop() */ public function createAliquotsTable() { - if (!Capsule::schema()->hasTable($this->tableName)) { - Capsule::schema()->create( + $db = Capsule::connection(); + $schema = Capsule::schema(); + + if (!$schema->hasTable($this->tableName)) { + $schema->create( $this->tableName, function ($table) { $table->increments('id'); @@ -91,9 +94,13 @@ function ($table) { // retenção de ISS $table->float('iss_held', 5, 2)->nullable(); $table->timestamp('created_at')->useCurrent(); - $table->timestamp('updated_at')->useCurrentOnUpdate(); + $table->timestamp('updated_at')->useCurrent(); } ); + + // Adiciona a coluna updated_at com a configuração de auto update #156 + $db->statement(sprintf('ALTER TABLE %s CHANGE updated_at updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', $this->tableName)); + } } diff --git a/modules/addons/NFEioServiceInvoices/lib/Models/ProductCode/Repository.php b/modules/addons/NFEioServiceInvoices/lib/Models/ProductCode/Repository.php index 0c3c944..80985a8 100644 --- a/modules/addons/NFEioServiceInvoices/lib/Models/ProductCode/Repository.php +++ b/modules/addons/NFEioServiceInvoices/lib/Models/ProductCode/Repository.php @@ -110,18 +110,25 @@ public function dropProductCodeTable() */ public function createProductCodeTable() { - if (!Capsule::schema()->hasTable($this->tableName)) { - Capsule::schema()->create( + $db = Capsule::connection(); + $schema = Capsule::schema(); + + if (!$schema->hasTable($this->tableName)) { + $schema->create( $this->tableName, function ($table) { $table->increments('id'); $table->integer('product_id'); $table->string('code_service', 30); $table->timestamp('created_at')->useCurrent(); - $table->timestamp('updated_at')->useCurrentOnUpdate(); + $table->timestamp('updated_at')->useCurrent(); $table->integer('ID_user'); } ); + + // Adiciona a coluna updated_at com a configuração de auto update #156 + $db->statement(sprintf('ALTER TABLE %s CHANGE updated_at updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', $this->tableName)); + } } diff --git a/modules/addons/NFEioServiceInvoices/lib/Models/ServiceInvoices/Repository.php b/modules/addons/NFEioServiceInvoices/lib/Models/ServiceInvoices/Repository.php index b58759f..60e5ef0 100644 --- a/modules/addons/NFEioServiceInvoices/lib/Models/ServiceInvoices/Repository.php +++ b/modules/addons/NFEioServiceInvoices/lib/Models/ServiceInvoices/Repository.php @@ -94,8 +94,11 @@ public function dataTable() */ public function createServiceInvoicesTable() { - if (!Capsule::schema()->hasTable($this->tableName)) { - Capsule::schema()->create( + $db = Capsule::connection(); + $schema = Capsule::schema(); + + if (!$schema->hasTable($this->tableName)) { + $schema->create( $this->tableName, function ($table) { // incremented id @@ -116,12 +119,16 @@ function ($table) { $table->string('rpsSerialNumber'); $table->string('rpsNumber'); $table->timestamp('created_at')->useCurrent(); - $table->timestamp('updated_at')->useCurrentOnUpdate(); + $table->timestamp('updated_at')->useCurrent(); $table->string('service_code', 30)->nullable(true); $table->string('tics')->nullable(true); } ); } + + // Adiciona a coluna updated_at com a configuração de auto update #156 + $db->statement(sprintf('ALTER TABLE %s CHANGE updated_at updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP', $this->tableName)); + } /**