workflows execute some tom commands on PostgreSQL

- added PostgreSQL connection to the tom example application
This commit is contained in:
silverqx
2022-05-23 16:29:45 +02:00
parent 2cb8bb9b4b
commit 4967700361
2 changed files with 65 additions and 24 deletions

View File

@@ -192,7 +192,7 @@ jobs:
run: >-
cmake --build ../TinyORM-builds-cmake/build-msvc-cmake-debug --target all --parallel 2
- name: Create and Seed tables for unit tests 🎉 (MySQL)
- name: Create and Seed tables for unit tests 🎉 (MySQL, PostgreSQL)
working-directory: ../TinyORM-builds-cmake/build-msvc-cmake-debug/tests/testdata_tom
run: |
$env:Path = '..\..;' + $env:Path
@@ -212,7 +212,7 @@ jobs:
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }}
TOM_TESTDATA_ENV: testing
- name: Create and Seed tables for unit tests (PostgreSQL, SQLite)
- name: Create and Seed tables for unit tests (SQLite)
working-directory: tests/testdata
run: |
php.exe ./create_and_seed_database.php --skip-mysql-migrate --skip-postgres-migrate
@@ -237,15 +237,15 @@ jobs:
DB_SQLITE_DATABASE: ${{ runner.temp }}/${{ secrets.DB_SQLITE_DATABASE }}
TOM_TESTS_ENV: testing
- name: Tom example execute migrate:status 🚀
- name: Tom example test some commands (MySQL) 🚀
working-directory: ../TinyORM-builds-cmake/build-msvc-cmake-debug/examples/tom
run: |
$env:Path = '..\..;' + $env:Path
.\tom.exe migrate:install --no-ansi
.\tom.exe migrate:status --no-ansi
.\tom.exe migrate --seed --no-ansi
.\tom.exe migrate:refresh --seed --no-ansi
.\tom.exe migrate:status --no-ansi
.\tom.exe migrate:install --database=tinyorm_tom_mysql --no-ansi
.\tom.exe migrate:status --database=tinyorm_tom_mysql --no-ansi
.\tom.exe migrate --seed --database=tinyorm_tom_mysql --no-ansi
.\tom.exe migrate:refresh --database=tinyorm_tom_mysql --seed --no-ansi
.\tom.exe migrate:status --database=tinyorm_tom_mysql --no-ansi
env:
DB_MYSQL_CHARSET: utf8mb4
DB_MYSQL_COLLATION: utf8mb4_0900_ai_ci
@@ -254,3 +254,20 @@ jobs:
DB_MYSQL_PASSWORD: ${{ secrets.DB_MYSQL_PASSWORD }}
DB_MYSQL_USERNAME: ${{ secrets.DB_MYSQL_USERNAME }}
TOM_EXAMPLE_ENV: testing
- name: Tom example test some commands (PostgreSQL) 🚀
working-directory: ../TinyORM-builds-cmake/build-msvc-cmake-debug/examples/tom
run: |
$env:Path = '..\..;' + $env:Path
.\tom.exe migrate:install --database=tinyorm_tom_postgres --no-ansi
.\tom.exe migrate:status --database=tinyorm_tom_postgres --no-ansi
.\tom.exe migrate --seed --database=tinyorm_tom_postgres --no-ansi
.\tom.exe migrate:refresh --database=tinyorm_tom_postgres --seed --no-ansi
.\tom.exe migrate:status --database=tinyorm_tom_postgres --no-ansi
env:
DB_PGSQL_CHARSET: utf8
DB_PGSQL_DATABASE: ${{ secrets.DB_PGSQL_DATABASE }}
DB_PGSQL_HOST: ${{ secrets.DB_PGSQL_HOST }}
DB_PGSQL_PASSWORD: ${{ secrets.DB_PGSQL_PASSWORD }}
DB_PGSQL_USERNAME: ${{ secrets.DB_PGSQL_USERNAME }}
TOM_EXAMPLE_ENV: testing

View File

@@ -67,23 +67,47 @@ std::shared_ptr<DatabaseManager> setupManager()
// Ownership of the shared_ptr()
return DB::create({
{driver_, QMYSQL},
{host_, qEnvironmentVariable("DB_MYSQL_HOST", H127001)},
{port_, qEnvironmentVariable("DB_MYSQL_PORT", P3306)},
{database_, qEnvironmentVariable("DB_MYSQL_DATABASE", EMPTY)},
{username_, qEnvironmentVariable("DB_MYSQL_USERNAME", EMPTY)},
{password_, qEnvironmentVariable("DB_MYSQL_PASSWORD", EMPTY)},
{charset_, qEnvironmentVariable("DB_MYSQL_CHARSET", UTF8MB4)},
{collation_, qEnvironmentVariable("DB_MYSQL_COLLATION", UTF8MB40900aici)},
{timezone_, TZ00},
{prefix_, EMPTY},
{prefix_indexes, true},
{strict_, true},
{isolation_level, QStringLiteral("REPEATABLE READ")},
{engine_, InnoDB},
{options_, QVariantHash()},
// MySQL connection
{QStringLiteral("tinyorm_tom_mysql"), {
{driver_, QMYSQL},
{host_, qEnvironmentVariable("DB_MYSQL_HOST", H127001)},
{port_, qEnvironmentVariable("DB_MYSQL_PORT", P3306)},
{database_, qEnvironmentVariable("DB_MYSQL_DATABASE", EMPTY)},
{username_, qEnvironmentVariable("DB_MYSQL_USERNAME", EMPTY)},
{password_, qEnvironmentVariable("DB_MYSQL_PASSWORD", EMPTY)},
{charset_, qEnvironmentVariable("DB_MYSQL_CHARSET", UTF8MB4)},
{collation_, qEnvironmentVariable("DB_MYSQL_COLLATION", UTF8MB40900aici)},
{timezone_, TZ00},
{prefix_, EMPTY},
{prefix_indexes, true},
{strict_, true},
{isolation_level, QStringLiteral("REPEATABLE READ")},
{engine_, InnoDB},
{options_, QVariantHash()},
}},
// PostgreSQL connection
{QStringLiteral("tinyorm_tom_postgres"), {
{driver_, QPSQL},
{host_, qEnvironmentVariable("DB_PGSQL_HOST", H127001)},
{port_, qEnvironmentVariable("DB_PGSQL_PORT", P5432)},
{database_, qEnvironmentVariable("DB_PGSQL_DATABASE", EMPTY)},
{schema_, qEnvironmentVariable("DB_PGSQL_SCHEMA", PUBLIC)},
{username_, qEnvironmentVariable("DB_PGSQL_USERNAME", postgres_)},
{password_, qEnvironmentVariable("DB_PGSQL_PASSWORD", EMPTY)},
{charset_, qEnvironmentVariable("DB_PGSQL_CHARSET", UTF8)},
// I don't use timezone types in postgres anyway
{timezone_, UTC},
{prefix_, EMPTY},
{prefix_indexes, true},
// ConnectionFactory provides a default value for this (for reference only)
// {dont_drop, QStringList {QStringLiteral("spatial_ref_sys")}},
{options_, QVariantHash()},
}}
},
QStringLiteral("tinyorm_tom"));
/* Because the default connection name is not defined, then will be needed
to provide the connection name using the --database=xyz argument. */
{});
}
/* Alternative syntax to instantiate migration classes. */