mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-21 16:46:33 +03:00
Support for adding a column to the beginning of a table
This commit is contained in:
parent
7c90c1e4c3
commit
e14de715f7
|
@ -83,10 +83,12 @@ class AlterTable(ModelOperation):
|
|||
is_regular_field = not (field.materialized or field.alias)
|
||||
if name not in table_fields:
|
||||
logger.info(' Add column %s', name)
|
||||
assert prev_name, 'Cannot add a column to the beginning of the table'
|
||||
cmd = 'ADD COLUMN %s %s' % (name, field.get_sql(db=database))
|
||||
if is_regular_field:
|
||||
cmd += ' AFTER %s' % prev_name
|
||||
if prev_name is not None:
|
||||
cmd += ' AFTER %s' % prev_name
|
||||
else:
|
||||
cmd += ' FIRST'
|
||||
self._alter_table(database, cmd)
|
||||
|
||||
if is_regular_field:
|
||||
|
|
Loading…
Reference in New Issue
Block a user