Description
There is a problem related to #2240. Luigi runs ALTER TABLE task_parameters ALTER COLUMN value TYPE TEXT
every time luigi.db_task_history.DbTaskHistory
is instantiated.
Normally this would be fine because it will not change anything if the type of value
is already TEXT
.
However, if you have a Postgres view that depends on this column, Postgres will refuse to run this instruction with an error message like DETAIL: rule _RETURN on view taskparameter_view depends on column "value"
.
There doesn't seem a sane way to make Postgres accept this statement, it seems to be necessary to drop the view (and all dependent views), run the ALTER TABLE
statement and re-create them.
It would be much nicer, if Luigi could check if the migration is actually necessary before executing that statement, similar to the way it checks for sqlite:
elif 'sqlite' in engine.dialect.name:
# SQLite does not support changing column types. A database file will need
# to be used to pickup this migration change.
for i in conn.execute('PRAGMA table_info(task_parameters);').fetchall():
if i['name'] == 'value' and i['type'] != 'TEXT':
logger.warning(
'SQLite can not change column types. Please use a new database '
'to pickup column type changes.'
)