340 Commits

Author SHA1 Message Date
silverqx
cf8f3e651c renamed seeder classes to singular 2022-05-17 08:30:01 +02:00
silverqx
48947bf3d2 added docs for seeding 📃 2022-05-16 21:04:32 +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
bf44d45573 added commented code 2022-05-16 10:22:26 +02:00
silverqx
9a06a5a92f cmake used absolute path 2022-05-12 16:11:46 +02:00
silverqx
da9608202d avoid migrations table names collision
tom example, main unit tests migrations and migrations table used during
unit testing have different names.
2022-05-12 13:52:23 +02:00
silverqx
2d0212f9c1 added TOM_TESTS_ENV to tst_migrate 2022-05-12 13:38:49 +02:00
silverqx
407c389cc8 added a new tom related env. variables to dotfiles 2022-05-12 13:38:11 +02:00
silverqx
285f654278 bugfix in skip-mysql-migrate condition 2022-05-12 13:01:11 +02:00
silverqx
3b05cd1bed used own tom migrations in unit tests 🎉 2022-05-12 12:25:22 +02:00
silverqx
b816c932dc removed unused code 2022-05-12 10:20:02 +02:00
silverqx
923d54567e cmake removed useless BUILD_INTERFACE 2022-05-10 16:08:45 +02:00
silverqx
2a43df8afe fixed clang-tidy warning on linux 2022-05-06 16:55:40 +02:00
silverqx
f7bbd743f5 fixed globals in tests
[skip ci]
2022-05-05 22:02:36 +02:00
silverqx
ffe1572cf5 used Tom_target in the tom.rc.in 2022-05-05 14:09:29 +02:00
silverqx
316b716a0b prepare migrations table in tst_migrate 2022-05-05 10:51:25 +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
b3105e0135 fixed RC file encoding problem (workaround) 2022-05-04 18:52:00 +02:00
silverqx
08c41ba9bd added new constant for utf80900 encoding 2022-05-04 10:56:28 +02:00
silverqx
c8976aaf11 udpated comment 2022-05-03 09:49:39 +02:00
silverqx
98c61891c3 enhanced migration classes naming
Migration classes can be named in two formats, CamelCase without the
datetime prefix and snake_case with the datetime prefix.

If the CamelCase name is used then the T_MIGRATION macro has to be
also used in the migration class.

 - also added a new validations of the migration class names
2022-05-02 10:59:30 +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
9933354594 moved tst_version auto test
Moved to the functional/others/ folder.
2022-04-25 15:22:36 +02:00
silverqx
97e9059ea4 fixed all clang-tidy and clazy warnings 2022-04-21 22:17:49 +02:00
silverqx
17c4c8b8d1 bugfix move migrate:reset test down
It can not be as the first test as migration table is not installed.
2022-04-21 18:48:15 +02:00
silverqx
91203b28ea missing includes without PCH on linux 2022-04-21 18:47:22 +02:00
silverqx
db45b4bd51 updated conf.pri.example 2022-04-21 16:22:49 +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
3595380cb9 added manager() getter to TinyUtils library 2022-04-13 19:36:32 +02:00
silverqx
80450d68b6 moved TINYORM_TESTS_CODE to TinyOrm.pri 2022-04-13 19:34:26 +02:00
silverqx
b6f9b7899a add indent in #ifdef 2022-04-13 19:18:11 +02:00
silverqx
9678e6e504 added unix gcc/clang support for schema builder
I had to reject designated initializers with commands because of gcc
throws -Wmissing-field-initializers warning with aggregates that have
a base class even empty base class, so I had to use classic aggregate
initialization with commands, it's not a big deal as all data members
of commands have to be initialized anyway as command aggregate classes
are tailor-made for a particular commands. I didn't want to suppress
this warning around every addCommand() method call.

 - mainly default init. of data members
 - some shadow/overlapping variable names in lambdas
 - missing SHAREDLIB_EXPORT for SchemmaGrammar
2022-03-25 16:45:16 +01:00
silverqx
9ecf531763 divided and allocated commands on the heap
Commands was extracted from the ColumnDefinition and has been created
own struct for every or very similar commands. They are now allocated
on the heap to save space because sizeof(ColumnDefinition) was 736 and
that is too much, eg if schema would contain 100 columns it would take
73KB.
I have decided not to use polymorphic commands, I wanted to use
designated initializers with aggregates, the consequence of this is
usage of reinterpret_cast() :/, but it works great.

 - renamed commands from XxCommandDefinition to XxCommand
 - get rid of a data member name collisions (eg index_, from_, ...)
   in the column and command definitions, consequence of division
   column and commands
2022-03-24 09:58:58 +01: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
bd889521db sync, exposed playground connection names 2022-03-06 12:23:25 +01:00
silverqx
37c5f6e0d5 sync torrent model, connection names constants 2022-02-23 11:15:23 +01:00
silverqx
7fed2e31e4 tests check transactions status
- bugfix reset savepoints during commit, rollBack
 - bugfix test all connections, forgotten code
2022-02-20 19:44:20 +01:00
silverqx
d5ad16fb06 added SIZE constant 2022-02-20 15:21:49 +01:00
silverqx
2ffad4e1ca added transaction unit tests
Also savepoints tested.
2022-02-20 12:14:13 +01:00
silverqx
d9e857d5ed added using consts. NAME 2022-02-12 13:16:53 +01:00
silverqx
cde15172c0 shared_ptr for DatabaseManager factory methods
Refactored from an unique_ptr to shared_ptr, I think this is a better
approach. Now it will be clear that a few DatabaseManager pointers are
stored somewhere in the TinyORM.

 - return std:shared_ptr from DatabaseManager factory methods
 - store a shared_ptr<DatabaseManager> in private data members in
   DatabaseManager and DB classes
2022-02-10 15:02:43 +01:00
silverqx
ac32a6d3c4 qmake enhanced precompiled headers 2022-02-09 07:41:47 +01:00
silverqx
71d22f2034 unified almost all throw exceptions 2022-01-17 19:07:59 +01:00
silverqx
7ffc2725fd removed useless return 2022-01-16 18:24:36 +01:00
silverqx
b734a09b53 fixed includes and typos 2022-01-15 11:08:01 +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
5f49aa54d0 fixed Orm:DB in torrent.hpp
After DB alias to Orm::DB was removed.
2022-01-13 17:08:33 +01:00
silverqx
c9cee67a13 removed DB alias to Orm::DB from global namespace 2022-01-13 15:40:11 +01:00
silverqx
94114e49c3 whitespace 2022-01-13 15:17:29 +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