mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-10 19:36:33 +03:00
Documentation
This commit is contained in:
parent
314090fa56
commit
395902b9c7
|
@ -1,6 +1,11 @@
|
|||
Change Log
|
||||
==========
|
||||
|
||||
Unreleased
|
||||
----------
|
||||
- Bug fix: add field names list explicitly to Database.insert method (anci)
|
||||
- Added RunPython and RunSQL migrations (M1hacka)
|
||||
|
||||
v0.9.7
|
||||
------
|
||||
- Add `distinct` method to querysets
|
||||
|
|
|
@ -32,16 +32,19 @@ Each migration file is expected to contain a list of `operations`, for example:
|
|||
|
||||
The following operations are supported:
|
||||
|
||||
|
||||
**CreateTable**
|
||||
|
||||
A migration operation that creates a table for a given model class. If the table already exists, the operation does nothing.
|
||||
|
||||
In case the model class is a `BufferModel`, the operation first creates the underlying on-disk table, and then creates the buffer table.
|
||||
|
||||
|
||||
**DropTable**
|
||||
|
||||
A migration operation that drops the table of a given model class. If the table does not exist, the operation does nothing.
|
||||
|
||||
|
||||
**AlterTable**
|
||||
|
||||
A migration operation that compares the table of a given model class to the model’s fields, and alters the table to match the model. The operation can:
|
||||
|
@ -52,6 +55,7 @@ A migration operation that compares the table of a given model class to the mode
|
|||
|
||||
Default values are not altered by this operation.
|
||||
|
||||
|
||||
**AlterTableWithBuffer**
|
||||
|
||||
A compound migration operation for altering a buffer table and its underlying on-disk table. The buffer table is dropped, the on-disk table is altered, and then the buffer table is re-created. This is the procedure recommended in the ClickHouse documentation for handling scenarios in which the underlying table needs to be modified.
|
||||
|
@ -61,24 +65,24 @@ Applying this migration operation to a regular table has the same effect as an `
|
|||
|
||||
**RunPython**
|
||||
|
||||
A migration operation that runs python function inside migration.
|
||||
|
||||
A migration operation that runs a Python function. The function receives the `Database` instance to operate on.
|
||||
|
||||
def forward(database):
|
||||
database.insert([
|
||||
TestModel(field=1)
|
||||
])
|
||||
|
||||
|
||||
operations = [
|
||||
RunPython(forward),
|
||||
migrations.RunPython(forward),
|
||||
]
|
||||
|
||||
|
||||
**RunSQL**
|
||||
|
||||
A migration operation that runs raw SQL queries inside migration.
|
||||
SQL parameter can be a string or array of SQL-query strings
|
||||
A migration operation that runs raw SQL queries. It expects a string containing an SQL query, or an array of SQL-query strings.
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
operations = [
|
||||
RunSQL('INSERT INTO `test_table` (field) VALUES (1)'),
|
||||
RunSQL([
|
||||
|
|
Loading…
Reference in New Issue
Block a user