Commit Graph

113 Commits

Author SHA1 Message Date
silverqx 0bcbcd2431 added support for PostgreSQL schema builder 🎉👌
- added a new config. option dont_drop, allows to define table that
   will be excluded during dropAllTables(), has a default value
   spatial_ref_sys for PostGIS
 - implemented fluent commands, used only by the PostgreSQL Comment
   command
 - added tests for PostgreSQL schema builder
 - reworked tst_Migrate to be able to run on all supported connections,
   currently PostgreSQL and MySQL
 - updated docs

Unrelated:

 - added a new reference class IndexDefinitionReference for a nice API
   during index definition, contains algorithm and language
 - unified selectFromWriteConnection() in schema builders
2022-05-23 10:14:25 +02:00
silverqx 2df4a9781f moved table guesser to the support folder 2022-05-17 16:18:27 +02:00
silverqx 13f1e30cc4 cmake added seeding support
- added TOM_SEEDERS_DIR option
2022-05-17 16:05:53 +02:00
silverqx 49d7b71dcb bugfix forgotten .cpp files 2022-05-17 16:04:59 +02:00
silverqx b8ad1c0bf0 moved Migration/SeederCreator to Support folder 2022-05-17 15:00:17 +02:00
silverqx bb731e1c22 added make:seeder command 👌
This command is very similar to the make:migration command except
the --create and --table command-line parameters. It provides the same
functionality but for seeders.

 - updated docs TINYTOM_SEEDERS_DIR macro and TOM_SEEDERS_DIR for cmake
2022-05-17 14:50:20 +02:00
silverqx d4557fc705 added database seeder 🔥🎉
The db:seed command invokes the root seeder DatabaseSeeder which can
invoke another seeders using the call() related methods. The root seeder
can be set by the --class command-line option and also by the --seeder
cmd. line option on some other commands like migrate:fresh/refresh.

Seeders can be passed to the Tom application in the similar way like the
migrations using the TomApplication::seeders<>() method or through the
constructor.

Arguments can be passed to the call<>() method, then the seeders run()
method will not be called using the virtual dispatch but using the type
traits. Of course the arguments passed to the call<>() method has to
match with the run() method parameters.

Others:

 - unified usingConnection() across all commands, this functionality was
   extracted to own class, previous it was a part of the Migrator class,
   so now every command even if it doesn't use Migrator can call
   the usingConnection() and it correctly sets a default connection and
   SQL queries debugging on the base of the -vvv command-line argument
 - a default database connection is now required, if not set then
   the exception will be thrown
 - added example seeders to the Tom application
2022-05-16 14:25:29 +02:00
silverqx 1b3b431873 extracted Model unguarded to own class
Extracting these guard related methods to own class allows to call
GuardedModel::unguarded() regardless of a template parameters needed
on the Model class, before was needed to call
Model<Torrent, Relations..>::unguarded().

 - also made the g_unguarded atomic
 - bugfix reguard() try-catch-finally in GuardedModel::unguarded()
2022-05-16 14:25:24 +02:00
silverqx 3b05cd1bed used own tom migrations in unit tests 🎉 2022-05-12 12:25:22 +02:00
silverqx 306796bc29 renamed TINY/TOM_MIGRATIONS_DIR
Renamed cmake option and macro from the TINY/TOM_MIGRATIONS_PATH to the
TINY/TOM_MIGRATIONS_DIR.

 - updated documentation
 - extracted init. code for the TINYTOM_MIGRATIONS_DIR to the own cmake
   macro
2022-05-10 18:16:31 +02:00
silverqx 923d54567e cmake removed useless BUILD_INTERFACE 2022-05-10 16:08:45 +02:00
silverqx ffe1572cf5 used Tom_target in the tom.rc.in 2022-05-05 14:09:29 +02:00
silverqx 2f455f7f4a fixed RC files encoding on Windows 🙌🎆
Use utf8 on MinGW and ANSI with msvc.

The core of the problem is in the $$cat() and write_file() qmake
functions they don't know process UTF-8 encoded files, they use
the ANSI encoding.
2022-05-05 10:31:29 +02:00
silverqx f4d730b552 bugfix cmake tom make:migration folder
Generate the initial TOM_MIGRATIONS_PATH with the BASE_DIRECTORY set
to the build folder and not to the source folder.
2022-05-03 17:00:13 +02:00
silverqx 9520716307 enhanced migration name logic for make:migration
Enhanced migration name detection for the make:migration, practically
all the possible combinations are allowed and handled correctly 👀😎.

Now is possible to pass the full migration name with the datetime prefix
and with the filename extension. All possible combinations are
supported.

Summarize, so an user can pass:

 - classname that will be converted to the studly case
 - filename without the datetime prefix (with or w/o extension)
 - filename with the datetime prefix (with or w/o extension)
2022-05-02 19:07:40 +02:00
silverqx 1a97c5e03b added table name guesser for make:migration 🚀
make:migration command is able to guess the table name and creation
status from the passed migration name on the command line.

If the migration name begins with the create_ string then the create
migration stub will be used.

If the migration name contains the (to|from|in)_ pattern then the update
migration stub will be used.

In all other cases an empty migration stub will be used.
2022-05-02 13:54:21 +02:00
silverqx 631280ad78 added string constants for tom
Created own tomconstants for the Tom namespace (folder tom/) and used
them everywhere.

Others:

 - removed Q_GLOBAL_STATIC_WITH_ARGS() in migrationcreator.cpp and used
   getter with the local static const
2022-04-28 13:03:46 +02:00
silverqx 373937958c provide custom migrations path to the tom example
User can provide a custom migrations path for the make:migration
command.

Default path is at database/migrations relative to the tom example
executable.

This allows to use the tom example as a real migration application and
the user doesn't have to create his own migration project.

Using:

 - TomApplication::migrationsPath()
 - TINYTOM_MIGRATIONS_PATH preprocessor macro, will be stringified
 - TOM_MIGRATIONS_PATH CMake PATH option
2022-04-26 19:56:48 +02:00
silverqx 4dda25105f updated all docs links to www.tinyorm.org 2022-04-25 15:10:32 +02:00
silverqx 7ba2e3cdae added guessing of namespace and command names 👌
Only partial names no matter of case can be passed, eg. mi:st for
the migrate:status, or m for the migrate command.
If the passed name is ambiguous then the error wall with all ambiguous
commands or namespaces is displayed, ambiguous commands also contain
a description.

Following positional arguments support guessing:

 - main command name at 0 position
 - command name passed to the help command
 - namespace name passed to the list command
2022-04-24 21:10:45 +02:00
silverqx c41db5738a added tabulate dependency to vcpkg port 2022-04-21 16:23:36 +02:00
silverqx a6213a6a9d added migrations 🔥🚀
Almost everything is implemented, possible to migrate up, down
(rollback), migrate by steps (works for up/down too), reset, refresh,
fresh, wipe database, showing status, installing migration table.

Command line interface is superb, it supports ansi coloring, verbosity,
no-interactive mode, force option, env option to select current env.

It has enhanced ansi coloring (vt100 terminal) detection, when ansi or
no-ansi option is not passed it can detect whether terminal supports
coloring.
Ansi coloring is disabled when redirection to file is detected (can
be overridden by ansi/no-ansi options).
Supports NO_COLOR env. variable (https://no-color.org/) and can detect
the ConEmu, Hyper, and xterm on Windows.

Carefully implemented help and list commands, list command can print
supported commands by namespace.

Advanced make migration command offers great command interface for
creating migration classes, supports options for generating empty,
create, or update migration classes.

Unfinished make project command, will support creating qmake, qmake
subproject, and cmake, cmake subproject projects. Later will be
extracted to own executable tomproject.exe for rapidly generating a new
TinyORM projects.

Other implemented commands are env that prints current env. and inspire
that displays an inspiring quote 😁.

Verbose supports 5 levels quiet, normal, verbose, very verbose, and
debug.

Possibility to disable compilation of the tom command related code using
TINYORM_DISABLE_TOM c macro, for the qmake exists disable_tom CONFIG
option and for the CMake exist TOM configuration option.

Confirmable interface that ask Y/N confirmation during migrate when
env. == production, can be overridden by --force option.

Whole tom terminal application supports or is implemented with UTF-8
support, also implemented UTF-16 output methods but they are not needed.
Input also supports UTF-8, currently only Y/N input is needed by the
Confirmation concern.

All migrate commands also support the --pretend option and the --env
option, when env. is production then tom asks confirmation to migrate,
it can be overridden by the --force option.

Added the tom example project, it is a complete command-line migration
application, it uses migrations from the tests.

Implementing this was really fun 🙃😎.

 - added 14 functional tests to test migrations up/down, stepping,
   installing migration table, refresh, reset on MySQL database
 - added unit test to check version number in tom.exe executable
 - new tom exception classes
 - created dozens of a new todo tasks 😂🤪, currently 348 todos 😎
 - added some info messages to the qmake build about building features
 - in the debug build and with the -vvv option enable debugging of sql
   queries
 - enhanced RC and manifest file generation, allowed to pass a custom
   basename for a RC/manifest file as the 3. argument and a custom
   replace token for the CMake genex as the 4. argument
 - bugfix disabled #pragma code_page(65001) // UTF-8 in RC files, it
   messes up the © character

Output of tom exe without arguments and options:

Common options:
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
      --env             The environment the command should run under
  -h, --help            Display help for the given command. When no
                        command is given display help for the list
                        command
  -n, --no-interaction  Do not ask any interactive question
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal
                        output, 2 for more verbose output and
                        3 for debug

Available commands:
  env                   Display the current framework environment
  help                  Display help for a command
  inspire               Display an inspiring quote
  list                  List commands
  migrate               Run the database migrations
 db
  db:wipe               Drop all tables, views, and types
 make
  make:migration        Create a new migration file
  make:project          Create a new Tom application project
 migrate
  migrate:fresh         Drop all tables and re-run all migrations
  migrate:install       Create the migration repository
  migrate:refresh       Rollback and re-run all migrations
  migrate:reset         Rollback all database migrations
  migrate:rollback      Rollback the last database migration
  migrate:status        Show the status of each migration
2022-04-20 15:45:35 +02:00
silverqx a2714be30e added schema builder 🔥🚀
Added practically everything I wanted to have in except for updating
columns.
Needed to name the schema namespace as Orm::SchemaNs to avoid collision
with the Orm::Schema class.

 - unit tests with great coverage
 - new schema constants
 - a new prefix_indexes and engine DB conncetion configurations

Others:

 - IsModel tag
 - enhanced columnize in the BaseGrammar
 - used a new columnize logic in all grammars
 - new constants
 - new container utils class for joining containers
 - new DB::driver() getter for QSqlDriver
 - avoid possible crash in tests with pretend, added empty log checks
 - clang tidy, excluded to word from short variable names
2022-03-22 09:53:33 +01:00
silverqx 043e26b920 removed empty cpp files 2022-01-17 16:25:29 +01:00
silverqx 8794b8b285 extracted relation types to own header file 2022-01-16 18:24:05 +01:00
silverqx bbfca1594e extracted transactions to ManagesTransactions
Transactions extracted to the Concerns::ManagesTransactions base class.

 - bugfix includes
 - logConnected()/logDisconnected() code wrapped in TINYORM_MYSQL_PING
 - hitTransactionalCounters() extracted to Concerns::CountsQueries
 - convertNamedToPositionalBindings() extracted to Concerns::LogsQueries
2022-01-14 21:26:02 +01:00
silverqx ff0697e1a5 extracted logging queries to LogQueries
Logging queries extracted to the Concerns::LogsQueries base class.
2022-01-14 17:37:58 +01:00
silverqx b36888ae93 extracted queries counters to CountsQueries
Queries counters extracted to the Concerns::CountsQueries base class.

 - removed ConnectionInterface 😕😎🙌
 - all methods are returning DatabaseConnection & instead of
   ConnectionInterface
 - includes cleanup after extraction
2022-01-14 16:04:17 +01:00
silverqx 097c2c0c22 cleanup, macro guards, inline, string/char literal
- explicit QStringLiteral and QChar
 - fixed macro guard names
 - inline from defn. to decl.
 - whitespaces and comments
 - added Q_DISABLE_COPY()
 - removed friend class DB; from DM
 - removed schemagrammar.cpp, was empty
2022-01-13 14:44:34 +01:00
silverqx fb20fd8b9f cleanup, macro guards, inline
- removed expression.cpp, Query::Expression is header only now
 - fixed macro guard names
 - inline from defn. to decl.
2022-01-13 11:02:07 +01:00
silverqx 280713bcd1 ConnectionOverride moved to own tiny types ns 2022-01-07 13:07:40 +01:00
silverqx b092191aa5 concepts divided to orm and tiny concepts 2022-01-07 12:54:34 +01:00
silverqx dbc375f1fe added HasRelationships concerns
Extracted appropriate methods from the Tiny::Model class to own
HasRelationships concerns.
2022-01-07 12:35:47 +01:00
silverqx 5a593224fe extracted CRTP static cast to own macro files
Added to macro files, one with derived model cast and another with
derived model cast and with cast to the base model.
2022-01-06 11:14:48 +01:00
silverqx 7a975f7b99 added HasAttributes and HasTimestamps concerns
Extracted appropriate methods from the Tiny::Model class to own
HasAttributes and HasTimestamps concerns.
2022-01-05 21:02:57 +01:00
silverqx f2212bd930 moved all ORM types to tinytypes.hpp 2022-01-03 19:18:53 +01:00
silverqx 657f39b104 moved SyncChanges to Tiny::Types 2022-01-03 13:11:01 +01:00
silverqx 087bf68999 moved LOG_EXECUTED_QUERY macro to own file 2022-01-01 16:31:59 +01:00
silverqx 92775f444c divided Orm::Utils
While ORM can be disabled, Orm::Utils has been split into Orm::Utils
and Orm::Tiny::Utils (Orm::Tiny::TinyUtils alias).
So when ORM is disabled then utils used only in the ORM will be
excluded from a final build.

 - bugfix cmake undefined ORM option in TinySources
2022-01-01 14:28:42 +01:00
silverqx fc477bf1e5 added qmake/cmake option to disable ORM
Added TINYORM_DISABLE_ORM macro controlled by ORM for CMake and
disable_orm for qmake. When TINYORM_DISABLE_ORM macro is defined then
only the query builder without ORM is compiled.
Also excludes ORM-related unit tests.
2021-12-31 11:40:12 +01:00
silverqx 869362bc7a added DISABLE_THREAD_LOCAL macro
Overrides default detection logic for thread_local and disable it
forcefully.
In qmake can be configured by "CONFIG+=disable_thread_local".
For Cmake DISABLE_THREAD_LOCAL option was added.
2021-12-30 17:12:29 +01:00
silverqx ece372e655 bugfix cmake multi-config
Fixed file(GENERATE OUTPUT) for versiondebug_cmake-<CONFIG>.hpp file.
2021-12-29 12:42:24 +01:00
silverqx eec136d9ce cmake reverted commented .rc file
It is needed, it was mistake.
2021-12-08 12:27:37 +01:00
silverqx 9aee6d4bed fixed clang-tidy diagnostics 2021-12-08 12:27:35 +01:00
silverqx 789063a2bc cmake enhanced vcpkg support
- allow using an environment variable VCPKG_ROOT instead of
   CMAKE_TOOLCHAIN_FILE command-line option
 - set VCPKG_TARGET_TRIPLET when VCPKG_DEFAULT_TRIPLET env. variable is
   defined
2021-12-08 12:27:35 +01:00
silverqx 09592a7732 added GitHub Actions Linux, MSYS2 UCRT64, MSVC
- initial g++/clang build, ctest on MSYS2 UCRT64 on Windows Server 2022
 - initial cmake build/ctest on Ubuntu 20.40
 - initial cmake build/ctest on MSVC on Windows Server 2019

changed driver to QPSQL in tst_databasemanager

This avoids crash when QMYSQL driver's dll is unavailable.
QMYSQL driver is not shipped by default by Qt Windows MSVC installer.
2021-12-08 12:27:25 +01:00
silverqx dcbb113fc8 added Fs::resolveHome()
It resolves ~ home prefix to the full filepath
2021-11-21 19:30:51 +01:00
silverqx 037207cd42 moved DatabaseConfiguration to support/ 2021-11-13 19:09:15 +01:00
silverqx 57da4a109e renamed macros.hpp to likely.hpp
It contained T_LIKELY/T_UNLIKELY only.
2021-11-12 20:40:02 +01:00
silverqx 3c3609a5b5 bugfix cmake removed LINKER: prefix 2021-11-12 18:11:40 +01:00