Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] calendar migration #112

Merged
merged 18 commits into from
Dec 8, 2014
Merged

[ADD] calendar migration #112

merged 18 commits into from
Dec 8, 2014

Conversation

hbrunn
Copy link
Member

@hbrunn hbrunn commented Oct 22, 2014

No description provided.

[IMP] use renamed modules from openupgrade_records
@hbrunn hbrunn added this to the 8.0 milestone Oct 22, 2014
@hbrunn hbrunn self-assigned this Oct 22, 2014
@hbrunn hbrunn changed the title [ADD] calendar migration (wip) [ADD] calendar migration Nov 3, 2014
@@ -50,7 +50,7 @@ Status :
+-----------------------------------+-----------------------------------+
|account_test | Nothing to do |
+-----------------------------------+-----------------------------------+
|account_voucher | done |
|account_voucher | Done |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be due to a bad rebased. Please check it.

@pedrobaeza
Copy link
Member

I don't see where crm_meeting_id column is renamed.

cr.execute(
'alter table calendar_event add column %s int' % (
openupgrade.get_legacy_name('crm_meeting_id'),
)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedrobaeza here i create the column

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I see now the trick.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But don't you think this should be on crm migration script instead here? You can for example install hr_holidays, that depends on calendar, but not crm, making this script fails.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really. crm.meeting was defined in base_calendar in 7.0, so you'll have that for every module depending on base_calendar. This is also why migrating it belongs into this migration script.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation.

@pedrobaeza
Copy link
Member

Very good work.

👍

@StefanRijnhart
Copy link
Member

Well done! Please include the changes to ir_cron_scheduler_alarm as printed by scripts/compare_noupdate_xml_records.py from the 7.0 server edition.

%s, calendar_alarm.id
from calendar_alarm join res_alarm
on %s=res_alarm.id
where %s=%s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you make work to migrate the links to the old calendar alarms, don't you need to migrating the existing res.alarm records to calendar.alarm?

@hbrunn
Copy link
Member Author

hbrunn commented Nov 17, 2014

@StefanRijnhart thanks for your pointers. The alarm migration was completely misguided, now I got it right I think. res.alarms by themselves never did anything, so I don't think there's something to migrate. But we need to migrate the relation between events and alarms and between meetings and alarms, that happens now.

@vaab
Copy link

vaab commented Dec 4, 2014

in function import_crm_meeting, line 81, you write:

cr.execute(
     '''update meeting_category_rel
        set event_id=calendar_event.id
        from calendar_event where event_id=%s''' % (
        openupgrade.get_legacy_name('crm_meeting_id'),
     )
)

But how can this work without breaking foreign key constraints ? Your event_id value is changed from integers pointing to crm_meeting table to integers pointing to calendar_event table...

I do get insert or update on table "meeting_category_rel" violates foreign key constraint "meeting_category_rel_event_id_fkey". while testing your code.

Sorry if I missed something important. Would be happy if you cleared out my mind on this topic.

@hbrunn
Copy link
Member Author

hbrunn commented Dec 4, 2014

thanks, you missed nothing. This worked in my test database out of simple coincidence

@hbrunn
Copy link
Member Author

hbrunn commented Dec 4, 2014

the commit above should fix it

@vaab
Copy link

vaab commented Dec 5, 2014

thx, the full calendar migration works now on my database. (~7000 crm_meetings)

pedrobaeza added a commit that referenced this pull request Dec 8, 2014
@pedrobaeza pedrobaeza merged commit d300b03 into OCA:8.0 Dec 8, 2014
@gwizo
Copy link

gwizo commented Dec 13, 2014

Having some issues with calendar migration as well not sure if its the same as the thread above. Trying to migrate from 7.0 to 8.0 .
2014-12-13 11:06:20,952 5045 INFO erp_migrated openerp.modules.migration: module hr_holidays: Running migration [>8.0.1.5] pre-migration
2014-12-13 11:06:20,952 5045 INFO erp_migrated openerp.modules.migration: module hr_holidays: Running migration [>8.0.1.5] pre-migration
2014-12-13 11:06:20,955 5045 ERROR erp_migrated openerp.sql_db: Programming error: column "openupgrade_legacy_8_0_crm_meeting_id" does not exist
LINE 3: from calendar_event where meeting_id=openupgrade_leg...
^
, in query update hr_holidays
set meeting_id=calendar_event.id
from calendar_event where meeting_id=openupgrade_legacy_8_0_crm_meeting_id
2014-12-13 11:06:20,956 5045 CRITICAL erp_migrated openerp.service.server: Failed to initialize database erp_migrated.
Traceback (most recent call last):
File "/var/tmp/openupgrade/8.0/server/openerp/service/server.py", line 901, in preload_registries
registry = RegistryManager.new(dbname, update_module=update_module)
File "/var/tmp/openupgrade/8.0/server/openerp/modules/registry.py", line 324, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/var/tmp/openupgrade/8.0/server/openerp/modules/loading.py", line 387, in load_modules
force, status, report, loaded_modules, update_module, upg_registry)
File "/var/tmp/openupgrade/8.0/server/openerp/modules/loading.py", line 295, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks, upg_registry=upg_registry)
File "/var/tmp/openupgrade/8.0/server/openerp/modules/loading.py", line 162, in load_module_graph
migrations.migrate_module(package, 'pre')
File "/var/tmp/openupgrade/8.0/server/openerp/modules/migration.py", line 179, in migrate_module
mod.migrate(self.cr, pkg.installed_version)
File "/var/tmp/openupgrade/8.0/addons/hr_holidays/migrations/8.0.1.5/pre-migration.py", line 30, in migrate
openupgrade.get_legacy_name('crm_meeting_id'),
File "/var/tmp/openupgrade/8.0/server/openerp/sql_db.py", line 158, in wrapper
return f(self, _args, *_kwargs)
File "/var/tmp/openupgrade/8.0/server/openerp/sql_db.py", line 234, in execute
res = self._obj.execute(query, params)
ProgrammingError: column "openupgrade_legacy_8_0_crm_meeting_id" does not exist
LINE 3: from calendar_event where meeting_id=openupgrade_leg...
^

@hbrunn hbrunn removed their assignment Jun 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants