mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Only attempt to migrate an old ODBC table if it still exists
This commit is contained in:
parent
38bf3bfc1c
commit
102dabdefc
@ -137,8 +137,13 @@ migrate_odbc1(Host, Tables, {OldTablesColumns, MigrateFun}) ->
|
|||||||
{[OldTable | _] = OldTables,
|
{[OldTable | _] = OldTables,
|
||||||
[OldColumns | _] = OldColumnsAll} = lists:unzip(OldTablesColumns),
|
[OldColumns | _] = OldColumnsAll} = lists:unzip(OldTablesColumns),
|
||||||
OldTablesA = [list_to_atom(Table) || Table <- OldTables],
|
OldTablesA = [list_to_atom(Table) || Table <- OldTables],
|
||||||
ColumnsT = [odbc_table_columns_t(OldTable1) || OldTable1 <- OldTables],
|
case is_table_exists(OldTable, odbc) of
|
||||||
migrate_odbc2(Host, Tables, OldTable, OldTables, OldColumns, OldColumnsAll, OldTablesA, ColumnsT, MigrateFun).
|
true ->
|
||||||
|
ColumnsT = [odbc_table_columns_t(OldTable1) || OldTable1 <- OldTables],
|
||||||
|
migrate_odbc2(Host, Tables, OldTable, OldTables, OldColumns, OldColumnsAll, OldTablesA, ColumnsT, MigrateFun);
|
||||||
|
false ->
|
||||||
|
ignored
|
||||||
|
end.
|
||||||
|
|
||||||
migrate_odbc2(Host, Tables, OldTable, OldTables, OldColumns, OldColumnsAll, OldTablesA, ColumnsT, MigrateFun)
|
migrate_odbc2(Host, Tables, OldTable, OldTables, OldColumns, OldColumnsAll, OldTablesA, ColumnsT, MigrateFun)
|
||||||
when ColumnsT == OldColumnsAll ->
|
when ColumnsT == OldColumnsAll ->
|
||||||
@ -236,3 +241,10 @@ odbc_table_columns_t(Table) ->
|
|||||||
Columns2
|
Columns2
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
is_table_exists(Table, odbc) ->
|
||||||
|
case catch ejabberd_odbc:sql_query_t("SELECT COUNT(*) FROM " ++ Table) of
|
||||||
|
{selected, _, _} ->
|
||||||
|
true;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user