Commit Graph

594 Commits

Author SHA1 Message Date
silverqx
0e3fb06d1b added ORM and TOM cmake options to github actions 2022-04-29 16:25:06 +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
9078fae60f fixed clang-tidy and clazy warnings 2022-04-28 17:04:42 +02:00
silverqx
aa1815927d removed todo task 2022-04-28 14:35:58 +02:00
silverqx
133d9e525a removed todo task 2022-04-28 13:03:56 +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
44584be459 removed fixed todo tasks 2022-04-25 16:00:38 +02:00
silverqx
9933354594 moved tst_version auto test
Moved to the functional/others/ folder.
2022-04-25 15:22:36 +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
e9ed083a18 fixed clang-tidy warning 2022-04-22 09:54:48 +02:00
silverqx
97e9059ea4 fixed all clang-tidy and clazy warnings 2022-04-21 22:17:49 +02:00
silverqx
91203b28ea missing includes without PCH on linux 2022-04-21 18:47:22 +02:00
silverqx
95ba86623d Merge branch 'migrations' into develop 2022-04-21 16:31:53 +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
342c167e5a bugfix shared_ptr for command definitions
Commands in the blueprint don't have virtual dtors, they are not
polymorphic, so shared_ptr has to be used because it can correctly
destroy these aggregates.
2022-04-14 16:33:27 +02:00
silverqx
0290212d36 removed todo task 2022-04-13 19:54:29 +02:00
silverqx
b9343e45d4 bugfix shared_ptr for command definitions
Commands in the blueprint don't have virtual dtors, they are not
polymorphic, so shared_ptr has to be used because it can correctly
destroy these aggregates.
2022-04-13 19:42:37 +02:00
silverqx
5cd54ebbef converted tiny utils to library classes
- added Type::isTrue()
 - added studly() and splitStringByWidth() to StringUtils
 - used using XxUtils for all Tiny library classes everywhere
2022-04-13 19:32:42 +02:00
silverqx
5ab1e7726a small changes 2022-04-13 19:25:26 +02:00
silverqx
d5f9632470 enhanced exception classes
- normalized comments
 - added a new std::string ctor
 - getters noexcept
2022-04-13 19:22:39 +02:00
silverqx
b6f9b7899a add indent in #ifdef 2022-04-13 19:18:11 +02:00
silverqx
d03d8fc972 tom initial commit
- finished qmake build
2022-03-27 16:12:44 +02:00
silverqx
723185eff9 added todo task 2022-03-27 08:11:18 +02:00
silverqx
7d81095a70 added todo task 2022-03-27 08:09:12 +02:00
silverqx
b311c86b61 added supportsSchemaTransactions() to schema 2022-03-26 19:38:42 +01:00
silverqx
b7cf779e83 bump to TinyORM v0.2.0 2022-03-26 17:34:27 +01:00
silverqx
24296dd4b3 fixtypo
- also updated comment
2022-03-26 16:54:17 +01:00
silverqx
9f587378a6 removed todo task 2022-03-26 09:25:06 +01:00
silverqx
2ca3edca94 added todo task 2022-03-25 17:33:06 +01: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
5126fd4369 whitespaces 2022-03-24 10:14:43 +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
c3318bdec7 updated comment 2022-03-22 11:34:01 +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
a7ace30999 unified constexpr static 2022-03-07 09:20:34 +01:00
silverqx
3bc8f43fd3 missing connection parameter in DB/DM
Added connection parameter to all methods in DB/DM.
2022-03-06 12:45:19 +01:00
silverqx
6751ac849b added containsConnection() to DB/DatabaseManager 2022-03-06 12:44:13 +01:00
silverqx
8e75deb53a added on() alias for connection()
It allows shorter syntax like DB::on(connection).
2022-03-06 12:43:08 +01:00
silverqx
25e5c066ff divided table() to table()/tableAs()
This allows to call table(table, connection) and it avoids following
call table(table, "", connection) if 'as' is empty.
2022-03-06 12:42:02 +01:00
silverqx
f268166f8f avoid to create physical connection for pretending
Added getQtQueryForPretend() that avoids to create physical connection
during pretend call when a physical DB connection was not created.
2022-03-06 12:37:48 +01:00
silverqx
80a1623b1d unified static constexpr
- also added const for STORE_TYPE
2022-03-06 12:34:36 +01:00
silverqx
1f4da6a6e4 missing inline 2022-03-06 12:33:46 +01:00
silverqx
98c207a7d9 added comment 2022-03-06 12:33:27 +01:00
silverqx
bbd36faeba added todo tasks 2022-03-06 12:32:43 +01:00
silverqx
9a54b520bc added isOpen()/connectEagerly()/pingDatabase()
- added connectEagerly() that allows to force connection to the DB
 - added isOpen()
 - exposed isOpen()/connectEagerly()/pingDatabase() to DB and
   DatabaseManager
2022-03-06 12:31:10 +01:00
silverqx
e79be8906c used __has_include() to check mysql.h
Used __has_include() in #if macro directives instead of checking
_MSC_VER or __MINGW32__ to include mysql.h file.

 - also modified #error directive calls
2022-03-06 12:22:04 +01:00
silverqx
4fc92a6e53 updated comment 2022-03-01 16:13:49 +01:00
silverqx
c932f091c4 updated comments and renamed method
- clarified comments about connect/reconnect logic
   in the DatabaseConnection
 - renamed refreshQtConnection() method.
2022-03-01 15:30:17 +01:00
silverqx
39b92f5716 bugfix during disconnect
Do nothing if TinyORM connection is not resolved.

 - also throw RuntimeError in getRawQtConnection() if TinyORM
   connection is not resolved
2022-03-01 15:28:51 +01:00