Commit Graph

61 Commits

Author SHA1 Message Date
silverqx
90fdb71dd3 fixed clang-tidy warning 2022-05-17 16:49:57 +02:00
silverqx
ec4775d82d removed unused constant 2022-05-17 16:19:41 +02:00
silverqx
2df4a9781f moved table guesser to the support folder 2022-05-17 16:18:27 +02:00
silverqx
ca93cd31a0 small updates of migrations and seeding 2022-05-17 15:16:47 +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
9ecc787ca4 made methods static 2022-05-17 14:30:16 +02:00
silverqx
65b13758b5 made throwIf method private 2022-05-17 13:44:23 +02:00
silverqx
926d72336f removed unused method 2022-05-17 13:44:03 +02:00
silverqx
74f356dbff removed todo task 2022-05-17 13:42:52 +02:00
silverqx
e1722bff1b bump versions TinyORM v0.4.0 and tom v0.2.0 2022-05-17 10:32:22 +02:00
silverqx
7913a825fa added todo task 2022-05-16 20:11:44 +02:00
silverqx
12ec27dd47 fixed clang-tidy warning and missing include 2022-05-16 17:59:41 +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
3b05cd1bed used own tom migrations in unit tests 🎉 2022-05-12 12:25:22 +02:00
silverqx
aa5b6f2ea9 bugfix don't show debug sql for db:wipe command 2022-05-12 10:22:04 +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
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
b3105e0135 fixed RC file encoding problem (workaround) 2022-05-04 18:52:00 +02:00
silverqx
67b15c3ffe tom, enhanced table guesser
Take into account also kebab-case 👀.
2022-05-03 12:39:41 +02:00
silverqx
f2563e7ae5 used static const QRegularExpression everywhere 2022-05-02 19:44:37 +02:00
silverqx
e70f589ba3 cut filename extension with path::stem 2022-05-02 19:33:50 +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
eaf0c72cd4 fixed migration stubs for make:migration command 2022-05-02 14:43:52 +02:00
silverqx
25a1087d7b bugfix table guesser regex
Use the lazy quantifiers, not greedy ones.
2022-05-02 14:04:01 +02:00
silverqx
33051614d8 bugfix gcc warning 2022-05-02 13:54:45 +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
c15e1ab7f3 fixed gcc Weffc warning 2022-05-02 13:48:56 +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
2e2b6e683a bugfix qt5 build missing #include 2022-04-29 10:30:17 +02:00
silverqx
da1470ffd5 finished printing options with values
- different render format for options with values --env[=ENV]
 - printing a default value part after the description
 - added some validations for option names, especially validate the size
 - fixed default value name in all commands, it should be upper
2022-04-29 08:32:47 +02:00
silverqx
b732f6f115 QLatin1String to QStringLiteral 😎 2022-04-28 17:22:42 +02:00
silverqx
9078fae60f fixed clang-tidy and clazy warnings 2022-04-28 17:04:42 +02:00
silverqx
a3c137b953 added support for the linux g++/clang 2022-04-28 13:10:25 +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
ae65961d89 fixed clang-tidy/clazy warnings 2022-04-27 08:18:07 +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
54cbc6f03e updated comment 2022-04-25 15:03:20 +02:00
silverqx
58d8b91e97 partial fix of tabulate locales on MSYS2 ucrt64 2022-04-25 14:33:41 +02:00
silverqx
e94d10076c renamed local variable 2022-04-25 12:28:29 +02:00
silverqx
4b4f072035 fixed msys2 g++/clang warnings 2022-04-25 12:18:00 +02:00
silverqx
f13ca22163 tried to make application methods const
Without success, I would have to create own parser for Command, I have
create FUTURE task for this.
2022-04-25 11:46:31 +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
13ab2db6df tom validate required positional arguments 2022-04-22 12:59:01 +02:00
silverqx
eb71a1f7de fix virtual dtors 2022-04-22 11:23:50 +02:00
silverqx
0017058348 enhanced terminal size detection 2022-04-22 10:31:08 +02:00
silverqx
6394c3975c removed struct keyword from decl 2022-04-22 10:28:02 +02:00
silverqx
fbd7d7f6c5 fixed clang-tidy warning 2022-04-22 10:06:21 +02:00
silverqx
aabcf7852b removed token from heredoc literals 2022-04-22 09:54:11 +02:00