Commit Graph

954 Commits

Author SHA1 Message Date
silverqx
39f8098932 added support for MSYS2 gcc/clang 2022-04-21 10:11:17 +02:00
silverqx
8c4990c111 tom finished make:migration command
Finished --path and --realpath options.

 - enhanced logic for checking whether a migration already exists
2022-04-20 17:11:58 +02:00
silverqx
f12dd24ef4 bugfix replaced String::splitStringByWidth()
Replaced algorithm that drives String::splitStringByWidth(), it was very
bugprone.
2022-04-20 17:04:20 +02:00
silverqx
9a91645df0 bugfix in String::splitStringByWidth() 2022-04-20 15:46:13 +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
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
acc5d1f0a2 added QT *= core sql to TinyOrm.pri 2022-04-13 19:37:23 +02:00
silverqx
3595380cb9 added manager() getter to TinyUtils library 2022-04-13 19:36:32 +02:00
silverqx
8db628b965 changed " to <> for #include 2022-04-13 19:35:07 +02:00
silverqx
80450d68b6 moved TINYORM_TESTS_CODE to TinyOrm.pri 2022-04-13 19:34:26 +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
16575bef58 docs added pragma once 2022-04-13 19:12:57 +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
6f8fad1441 sync docs, bugfixes found during examples testing
Fixed problems that I have found during building of all schema builder
examples.
2022-03-26 18:25:40 +01:00
silverqx
99d909b145 sync docs 2022-03-26 18:03:58 +01:00
silverqx
b7cf779e83 bump to TinyORM v0.2.0 v0.2.0 2022-03-26 17:34:27 +01:00
silverqx
190163d278 sync docs, added docs for Schema builder 2022-03-26 17:22:22 +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
52567f6935 bugfix msys2 qmake build 2022-03-25 21:33:13 +01:00
silverqx
d1fc390e17 fixed clazy warning
Fixed clazy-use-static-qregularexpression warning.

 - also renamed re local variables to regex
2022-03-25 18:03:09 +01:00
silverqx
2ca3edca94 added todo task 2022-03-25 17:33:06 +01:00
silverqx
d2bd40988d bugfix mysql.h include
Switched __has_include() condition, moved mysql/mysql.h higher to avoid
warnings from mysql.h with -isystem includes.
2022-03-25 16:53:41 +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
f185e76cfa partial bugfix avoid exceptions in transactions
Partial bugfix getQtConnection() during transactions, it causes
exceptions, used getRawQtConnection() instead, still needs some work.
2022-03-06 12:49:02 +01:00
silverqx
80b0038914 updated notes
Added how to upgrade Docusaurus to the NOTES.txt.
2022-03-06 12:46:34 +01:00
silverqx
3cc40ae0a4 sync docs, added Qt 6 to dependencies 2022-03-06 12:45:47 +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
312ef9dba7 bugfix ! Q_ASSERT() 😮 2022-03-06 12:35:25 +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