mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-04-30 05:29:57 -05:00
schema added datetimes and softDeletesDatetime
Added the datetimes() and softDeletesDatetime() shortcut methods to the Blueprint. - updated docs
This commit is contained in:
@@ -544,6 +544,7 @@ The schema builder blueprint offers a variety of methods that correspond to the
|
||||
[Char](#column-method-Char)
|
||||
[dateTimeTz](#column-method-dateTimeTz)
|
||||
[dateTime](#column-method-dateTime)
|
||||
[datetimes](#column-method-datetimes)
|
||||
[date](#column-method-date)
|
||||
[decimal](#column-method-decimal)
|
||||
[Double](#column-method-Double)
|
||||
@@ -576,6 +577,7 @@ The schema builder blueprint offers a variety of methods that correspond to the
|
||||
[smallIncrements](#column-method-smallIncrements)
|
||||
[smallInteger](#column-method-smallInteger)
|
||||
[softDeletes](#column-method-softDeletes)
|
||||
[softDeletesDatetime](#column-method-softDeletesDatetime)
|
||||
[softDeletesTz](#column-method-softDeletesTz)
|
||||
[string](#column-method-string)
|
||||
[text](#column-method-text)
|
||||
@@ -653,6 +655,12 @@ The `dateTime` method creates a `DATETIME` equivalent column with an optional pr
|
||||
|
||||
table.dateTime("created_at", precision = 0);
|
||||
|
||||
#### `datetimes()` {#column-method-datetimes}
|
||||
|
||||
The `datetimes` method creates `created_at` and `updated_at` `DATETIME` equivalent columns with an optional precision (total digits):
|
||||
|
||||
table.datetimes(precision = 0);
|
||||
|
||||
#### `date()` {#column-method-date}
|
||||
|
||||
The `date` method creates a `DATE` equivalent column:
|
||||
@@ -849,6 +857,12 @@ The `softDeletes` method adds a nullable `deleted_at` `TIMESTAMP` equivalent col
|
||||
|
||||
table.softDeletes("deleted_at", precision = 0);
|
||||
|
||||
#### `softDeletesDatetime()` {#column-method-softDeletesDatetime}
|
||||
|
||||
The `softDeletesDatetime` method adds a nullable `deleted_at` `DATETIME` equivalent column with an optional precision (total digits). This column is intended to store the `deleted_at` timestamp needed for TinyORM's "soft delete" functionality:
|
||||
|
||||
table.softDeletesDatetime("deleted_at", precision = 0);
|
||||
|
||||
#### `softDeletesTz()` {#column-method-softDeletesTz}
|
||||
|
||||
The `softDeletesTz` method adds a nullable `deleted_at` `TIMESTAMP` (with timezone) equivalent column with an optional precision (total digits). This column is intended to store the `deleted_at` timestamp needed for TinyORM's "soft delete" functionality:
|
||||
|
||||
@@ -327,6 +327,9 @@ namespace Grammars
|
||||
/*! Add creation and update timestampTz columns to the table. */
|
||||
void timestampsTz(int precision = 0);
|
||||
|
||||
/*! Add creation and update datetime columns to the table. */
|
||||
inline void datetimes(int precision = 0);
|
||||
|
||||
/*! Add a "deleted at" timestamp for the table. */
|
||||
ColumnDefinitionReference<>
|
||||
softDeletes(const QString &column = Orm::Constants::DELETED_AT,
|
||||
@@ -336,6 +339,11 @@ namespace Grammars
|
||||
softDeletesTz(const QString &column = Orm::Constants::DELETED_AT,
|
||||
int precision = 0);
|
||||
|
||||
/*! Add a "deleted at" datetime column to the table. */
|
||||
inline ColumnDefinitionReference<>
|
||||
softDeletesDatetime(const QString &column = Orm::Constants::DELETED_AT,
|
||||
int precision = 0);
|
||||
|
||||
/*! Create a new year column on the table. */
|
||||
ColumnDefinitionReference<> year(const QString &column);
|
||||
|
||||
@@ -695,6 +703,19 @@ namespace Grammars
|
||||
return decimal(column, total, places, true);
|
||||
}
|
||||
|
||||
void Blueprint::datetimes(const int precision)
|
||||
{
|
||||
dateTime(Orm::Constants::CREATED_AT, precision).nullable();
|
||||
|
||||
dateTime(Orm::Constants::UPDATED_AT, precision).nullable();
|
||||
}
|
||||
|
||||
ColumnDefinitionReference<>
|
||||
Blueprint::softDeletesDatetime(const QString &column, const int precision)
|
||||
{
|
||||
return dateTime(column, precision).nullable();
|
||||
}
|
||||
|
||||
const QString &Blueprint::getTable() const noexcept
|
||||
{
|
||||
return m_table;
|
||||
|
||||
Reference in New Issue
Block a user