-
-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3489 from ForgeFlow/v15_mig_google_calendar
[15.0][MIG] google_calendar: migration script
- Loading branch information
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
openupgrade_scripts/scripts/google_calendar/15.0.1.0/post-migration.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from openupgradelib import openupgrade | ||
|
||
|
||
def _move_credentials_from_res_users_to_google_calendar_credentials(env): | ||
openupgrade.logged_query( | ||
env.cr, | ||
""" | ||
WITH google_calendar_credentials_tmp AS ( | ||
INSERT INTO google_calendar_credentials AS cc ( | ||
calendar_rtoken, calendar_token, calendar_token_validity, | ||
calendar_sync_token, calendar_cal_id, synchronization_stopped, | ||
create_uid, create_date, write_uid, write_date) | ||
SELECT u.google_calendar_rtoken, u.google_calendar_token, | ||
u.google_calendar_token_validity, u.google_calendar_sync_token, | ||
u.google_calendar_cal_id, FALSE, max(u.write_uid), max(u.write_date), | ||
max(u.write_uid), max(u.write_date) | ||
FROM res_users u | ||
WHERE u.google_calendar_token IS NOT NULL | ||
GROUP BY u.google_calendar_rtoken, u.google_calendar_token, | ||
u.google_calendar_token_validity, u.google_calendar_sync_token, | ||
u.google_calendar_cal_id | ||
RETURNING cc.id, cc.calendar_token | ||
) | ||
UPDATE res_users u | ||
SET google_cal_account_id = tmp.id | ||
FROM google_calendar_credentials_tmp as tmp | ||
WHERE tmp.calendar_token = u.google_calendar_token | ||
""", | ||
) | ||
|
||
|
||
@openupgrade.migrate() | ||
def migrate(env, version): | ||
_move_credentials_from_res_users_to_google_calendar_credentials(env) |
32 changes: 32 additions & 0 deletions
32
openupgrade_scripts/scripts/google_calendar/15.0.1.0/upgrade_analysis_work.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
---Models in module 'google_calendar'--- | ||
new model google.calendar.credentials | ||
---Fields in module 'google_calendar'--- | ||
google_calendar / google.calendar.credentials / calendar_cal_id (char) : NEW | ||
google_calendar / google.calendar.credentials / calendar_rtoken (char) : NEW | ||
google_calendar / google.calendar.credentials / calendar_sync_token (char) : NEW | ||
google_calendar / google.calendar.credentials / calendar_token (char) : NEW | ||
google_calendar / google.calendar.credentials / calendar_token_validity (datetime): NEW | ||
google_calendar / google.calendar.credentials / synchronization_stopped (boolean): NEW | ||
google_calendar / google.calendar.credentials / user_ids (one2many) : NEW relation: res.users, required | ||
google_calendar / res.users / google_cal_account_id (many2one): NEW relation: google.calendar.credentials | ||
# NOTHING TO DO: new feature | ||
|
||
google_calendar / res.users / google_calendar_cal_id (char) : not stored anymore | ||
google_calendar / res.users / google_calendar_cal_id (char) : now related | ||
google_calendar / res.users / google_calendar_rtoken (char) : not stored anymore | ||
google_calendar / res.users / google_calendar_rtoken (char) : now related | ||
google_calendar / res.users / google_calendar_sync_token (char): not stored anymore | ||
google_calendar / res.users / google_calendar_sync_token (char): now related | ||
google_calendar / res.users / google_calendar_token (char) : not stored anymore | ||
google_calendar / res.users / google_calendar_token (char) : now related | ||
google_calendar / res.users / google_calendar_token_validity (datetime): not stored anymore | ||
google_calendar / res.users / google_calendar_token_validity (datetime): now related | ||
# DONE: move credentials from res_user table to google_calendar_credentials table | ||
|
||
---XML records in module 'google_calendar'--- | ||
NEW ir.model.access: google_calendar.access_google_calendar_credentials | ||
NEW ir.model.access: google_calendar.google_calendar_manager | ||
DEL ir.ui.view: google_calendar.assets_backend | ||
DEL ir.ui.view: google_calendar.qunit_mobile_suite | ||
DEL ir.ui.view: google_calendar.qunit_suite | ||
# NOTHING TO DO: noupdate="0" records |