diff options
author | Matthew Wild <mwild1@gmail.com> | 2011-06-03 00:58:09 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2011-06-03 00:58:09 +0100 |
commit | 8f23723f94af0fd03541b33e0a4e647dfc743d00 (patch) | |
tree | c714d4a7da3a44ffa9e988531b178b8c0693d73b /tools/migration/migrator/prosody_sql.lua | |
parent | 1fbb80b14b54c36a3f9aff974a489f7dda0917ea (diff) | |
parent | 27bc9300b89d76c5ef59e13653a9d67267830522 (diff) | |
download | prosody-8f23723f94af0fd03541b33e0a4e647dfc743d00.tar.gz prosody-8f23723f94af0fd03541b33e0a4e647dfc743d00.zip |
Merge 0.8->trunk
Diffstat (limited to 'tools/migration/migrator/prosody_sql.lua')
-rw-r--r-- | tools/migration/migrator/prosody_sql.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/migration/migrator/prosody_sql.lua b/tools/migration/migrator/prosody_sql.lua index 50ae8c40..ec86417c 100644 --- a/tools/migration/migrator/prosody_sql.lua +++ b/tools/migration/migrator/prosody_sql.lua @@ -21,6 +21,8 @@ local function create_table(connection, params) local create_sql = "CREATE TABLE `prosody` (`host` TEXT, `user` TEXT, `store` TEXT, `key` TEXT, `type` TEXT, `value` TEXT);"; if params.driver == "PostgreSQL" then create_sql = create_sql:gsub("`", "\""); + elseif params.driver == "MySQL" then + create_sql = create_sql:gsub("`value` TEXT", "`value` MEDIUMTEXT"); end local stmt = connection:prepare(create_sql); @@ -40,6 +42,22 @@ local function create_table(connection, params) ok, err = assert(stmt:execute()); commit_ok, commit_err = assert(connection:commit()); end + else -- COMPAT: Upgrade tables from 0.8.0 + -- Failed to create, but check existing MySQL table here + local stmt = connection:prepare("SHOW COLUMNS FROM prosody WHERE Field='value' and Type='text'"); + local ok = stmt:execute(); + local commit_ok = connection:commit(); + if ok and commit_ok then + if stmt:rowcount() > 0 then + local stmt = connection:prepare("ALTER TABLE prosody MODIFY COLUMN `value` MEDIUMTEXT"); + local ok = stmt:execute(); + local commit_ok = connection:commit(); + if ok and commit_ok then + print("Database table automatically upgraded"); + end + end + repeat until not stmt:fetch(); + end end end end |