Skip to content

Commit

Permalink
internal(migration): prevent specifying foreign index names for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Nov 29, 2023
1 parent e304775 commit a27e300
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

use CodeIgniter\Database\Migration;

use Config\Database;

class CreateCurrencies extends Migration
{
public function up()
{
$database = Database::connect();

$this->forge->addField([
"id" => [
"type" => "BIGINT",
Expand Down Expand Up @@ -36,7 +40,9 @@ public function up()
"id",
"CASCADE",
"CASCADE",
"currencies_user_id_foreign"
$database->DBDriver === "SQLite3"
? "currencies_user_id_foreign"
: null
);
$this->forge->createTable("currencies");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;

use Config\Database;

class CreateAccountsTable extends Migration
{
public function up()
{
$database = Database::connect();

$this->forge->addField([
"id" => [
"type" => "BIGINT",
Expand Down Expand Up @@ -52,7 +56,9 @@ public function up()
"id",
"CASCADE",
"CASCADE",
"accounts_currency_id_foreign"
$database->DBDriver === "SQLite3"
? "accounts_currency_id_foreign"
: null
);
$this->forge->createTable("accounts");
}
Expand Down
12 changes: 10 additions & 2 deletions app/Database/Migrations/2023-07-26-022116_CreateModifiersTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;

use Config\Database;

class CreateModifiersTable extends Migration
{
public function up()
{
$database = Database::connect();

$this->forge->addField([
"id" => [
"type" => "BIGINT",
Expand Down Expand Up @@ -56,15 +60,19 @@ public function up()
"id",
"CASCADE",
"CASCADE",
"modifiers_debit_account_id_foreign"
$database->DBDriver === "SQLite3"
? "modifiers_debit_account_id_foreign"
: null
);
$this->forge->addForeignKey(
"credit_account_id",
"accounts",
"id",
"CASCADE",
"CASCADE",
"modifiers_credit_account_id_foreign"
$database->DBDriver === "SQLite3"
? "modifiers_credit_account_id_foreign"
: null
);
$this->forge->createTable("modifiers");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;

use Config\Database;

class CreateFinancialEntriesTable extends Migration
{
public function up()
{
$database = Database::connect();

$this->forge->addField([
"id" => [
"type" => "BIGINT",
Expand Down Expand Up @@ -54,7 +58,9 @@ public function up()
"id",
"CASCADE",
"CASCADE",
"financial_entries_modifier_id_foreign"
$database->DBDriver === "SQLite3"
? "financial_entries_modifier_id_foreign"
: null
);
$this->forge->createTable("financial_entries");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

use CodeIgniter\Database\Migration;

use Config\Database;

class CreateFrozenPeriodsTable extends Migration
{
public function up()
{
$database = Database::connect();

$this->forge->addField([
"id" => [
"type" => "BIGINT",
Expand All @@ -32,7 +36,9 @@ public function up()
"id",
"CASCADE",
"CASCADE",
"frozen_periods_user_id_foreign"
$database->DBDriver === "SQLite3"
? "frozen_periods_user_id_foreign"
: null
);
$this->forge->createTable("frozen_periods");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
use CodeIgniter\Database\Migration;
use CodeIgniter\Database\RawSql;

use Config\Database;

class CreateSummaryCalculationsTable extends Migration
{
public function up()
{
$database = Database::connect();

$this->forge->addField([
"id" => [
"type" => "BIGINT",
Expand Down Expand Up @@ -43,15 +47,19 @@ public function up()
"id",
"CASCADE",
"CASCADE",
"summary_calculations_frozen_period_id_foreign"
$database->DBDriver === "SQLite3"
? "summary_calculations_frozen_period_id_foreign"
: null
);
$this->forge->addForeignKey(
"account_id",
"accounts",
"id",
"CASCADE",
"CASCADE",
"summary_calculations_account_id_foreign"
$database->DBDriver === "SQLite3"
? "summary_calculations_account_id_foreign"
: null
);
$this->forge->createTable("summary_calculations");
}
Expand Down

0 comments on commit a27e300

Please sign in to comment.