Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Migrate all custom fields declare by pmorganization to field_api based fields. Also declare a field that other could use to reference pmorganization.
Fields to be migrated are.
Status: DRAFT (not yet agreed upon field types and name.)
- country to pmorganization_country (select list)
- orglanguage to pmorganization_language (select list)
- provstate to pmorganization_provstate (text field)
- city to pmorganization_city (text field)
- zip to pmorganization_zip (text field)
- address to pmorganization_address (textarea)
- taxid to pmorganization_taxid (text field)
- email to pmorganization_email (text field)
- www to pmorganization_www (text field)
- phone to pmorganization_phone (text field)
- currency to pmorganization_currency (select list)
- iscustomer to pmorganization_iscustomer (check box)
- isprovider to pmorganization_isprovider (check box)
- isactive to pmorganization_isactive (check box)
- pricemode to pmorganization_pricemode (select list)
- price to pmorganization_price (text field)
- body to body (migration code pending)
Fields needed to be declared by not used.
- pmorganization_id
Points to be discussed:
- Use of address field.
- Use of email field
- Use of phone field
- Use of link field
- Merging iscustomer, isprovider & isactive to single field ( multiple checkboxes).
References:
#1915320-30: Move to a Field API based approach
#1997488-10: Tips for Migrating from Storm to PM
Comment | File | Size | Author |
---|---|---|---|
#40 | issue-2041659-39-pmorganization-migrate.patch | 166.05 KB | D34dMan |
Comments
Comment #1
Raphael Dürst CreditAttribution: Raphael Dürst commentedAren't there also a lot of fields which we could declare with pm and then just use instances of these for the different pm content types?
I'm talking about fields like price and duration which are used by a lot of pm content types.
Comment #2
D34dMan CreditAttribution: D34dMan commentedNice idea, can you please list the fields so we could discuss regarding the list, what goes into pm and what doesn't.
Comment #3
Raphael Dürst CreditAttribution: Raphael Dürst commentedI made a list with all fields which occur in more than one pm module:
Maybe we could also handle the TYPEcategory, TYPEstatus and TYPEpriority fields differently.
Edit:
Also, instead of using checkboxes for billed and billable, we could use a dropdown with the values not billable, billable and billed (I don't think there is a usecase, where something is billed but not billable).
Comment #4
juliangb CreditAttribution: juliangb commentedCould I propose that we start with pm note? I think the selection of fields is simpler and a good place to demonstrate a proof of concept.
Comment #5
Raphael Dürst CreditAttribution: Raphael Dürst commentedI just looked, what fields in pmnote we could migrate, but the only fields are organization_nid, project_nid & task_nid.
But if we want to declare the entity references in their respective modules (organization_nid in pmorganization, ...) we can't really start with pmnote.
And there are no other fields to convert in pmnote.
So, I guess we have to start with pmorganization, even if it is a pretty big one.
Comment #6
D34dMan CreditAttribution: D34dMan commentedor we can have a micro patch for pmorganization, pmtask and pmticket ( just the reference field ) and then do a mega patch for pmnote.
Comment #7
juliangb CreditAttribution: juliangb commented#6 is pretty much what I was thinking.
The challenge is to split this functionality into distinct chunks that make sense, but also allow us to start testing.
I think once we start testing patches there will be things that we realise that will help guide the change across the remaining modules.
Comment #8
Raphael Dürst CreditAttribution: Raphael Dürst commentedOk, that makes sense.
Then we should start by creating the entity reference fields for organization, project and task.
After that, we can start migrating pmnote.
Should we open a new issue for the reference fields?
Comment #9
D34dMan CreditAttribution: D34dMan commentedI suggest we create a separate issue per content type. And then list all the fields that needs to be implemented in the issue description. After that, when a micro patch is commited, we update the issue description by striking off (
like this) the relevant field from the list.Am not able to work much on weekdays, so un-assigning myself if anybody wants to work on it.
Comment #10
Raphael Dürst CreditAttribution: Raphael Dürst commentedI created a field for pmorganization_nid.
I named it pmorganization_ref since it is a entity reference.
It's actually pretty easy. After reinstalling pm & pmorganization the field appears correctly in the database in the field_config table.
I also added a dependency for entityreference to the pm module.
Edit: Useful information for creating entityreference fields: Adding entityreference fields programmatically
Comment #11
D34dMan CreditAttribution: D34dMan commentedI think we can move it to hook_update_N() so the fields are created when we run update.php. An uninstall would cause lots of undesired effects.
Comment #12
Raphael Dürst CreditAttribution: Raphael Dürst commentedYes, but it should also be in hook_install, otherwise the field won't be created for people who newly install the module. They won't run an update.
Comment #14
Raphael Dürst CreditAttribution: Raphael Dürst commentedThe test seems to be failing because entityreference is not enabled in setUp().
I added it in the pm & pmorganization test, the other modules might still fail the test.
Also added the field to hook_update_N.
Comment #16
Raphael Dürst CreditAttribution: Raphael Dürst commentedStrange, if I run the tests on my local installation, they pass the tests.
I don't know what's causing the tests to fail...
Comment #17
juliangb CreditAttribution: juliangb commentedThis is the testbot's fault - it caches dependencies and so doesn't pick up the new dependency in this patch.
Let's review manually, and once we get to wanting to commit we can commit the dependency then test the patch, to show it passes on d.o. too.
Comment #18
dbt102 CreditAttribution: dbt102 commentedI tried applying patch. In terminal, usually when I run the ' git apply ' patch command it comes back and tells that the patch applied cleanly. It did not do that for this patch. After aplying it just came back to command line, so it seemed work...
Comment #19
juliangb CreditAttribution: juliangb commented@dbt102 Could you try
git apply -v [filename]
? It will give more details about whether it was ok or not.Comment #20
Raphael Dürst CreditAttribution: Raphael Dürst commentedOk, I removed the entityreference from setUp() in the tests and ran them again.
They all passed with this patch.
Comment #22
dbt102 CreditAttribution: dbt102 commentedHad to install Entityreference module and enabled both of them, and this had a dependency on Entity module as well, so enabled both of them.
After I had the additional dependencies loaded then update.php completed OK.
Testing.... seems to work OK. Created new organization and filled in all fields and saved OK.
Edit: This per patch in comment #14
Comment #23
Raphael Dürst CreditAttribution: Raphael Dürst commentedThis patch doesn't actually change anything at the functionality of pmorganization at the moment, it only creates the field at installation/update.
But to see if it really worked, you can check out the database.
In the table field_config you should see an entry with the field_name pmorganization_ref and you should also see the tables field_data_pmorganziation_ref and field_revision_pmorganziation_ref.
Comment #24
dbt102 CreditAttribution: dbt102 commentedOK ... Thanks ... I see them all
Comment #25
D34dMan CreditAttribution: D34dMan commentedWill have to modify testcase to enable entityreference. Otherwise it will always fail. This applies to pmtask and pmticket as well.
Comment #26
D34dMan CreditAttribution: D34dMan commentedentityreference, entity and ctools to be precise.
Comment #27
Raphael Dürst CreditAttribution: Raphael Dürst commentedAs julian wrote in #17, it's because the dependencies are cached and you have to commit the depencency first.
In the patch in #13 I added the modules to the testcase and it didn't work.
Comment #28
juliangb CreditAttribution: juliangb commentedI was testing this today with the intention of creating field instances and testing moving data between them, but after successfully applying the patch I did not see these fields on the "existing fields" drop down on the "manage fields" page of a content type.
Are these fields only usable if we create field instances in code?
The next steps for these patches are really to implement specific instances of them. I'm happy to commit a dependency when we're close to being ready.
Comment #29
Raphael Dürst CreditAttribution: Raphael Dürst commentedI just tested this myself.
I guess, "Add existing field" only shows fields with existing instances.
But when I created an instance of pmorganization_ref in pmproject, the new field showed up on pmproject and was also available in other content types (e.g. pmtask).
I only had to add this code and it already worked:
Comment #30
Raphael Dürst CreditAttribution: Raphael Dürst commented#20: 2041659-pmorganization_ref-17.patch queued for re-testing.
Comment #31
dbt102 CreditAttribution: dbt102 commentedPatch failed. (Did you know that it would?) Here is terminal output...
ubuntu:$ git reset --hard
HEAD is now at b493b60 Add date dependency to dev
ubuntu:$ git pull origin
Already up-to-date.
ubuntu:$ git apply -v 2041659-pmorganization_ref-17.patch
Checking patch pm.info...
error: while searching for:
configure = admin/config/pm
files[] = pm.test
dependencies[] = views
error: patch failed: pm.info:5
error: pm.info: patch does not apply
Checking patch pmorganization/pmorganization.install...
Comment #32
juliangb CreditAttribution: juliangb commentedThis patch won't apply because the dependency has already been committed to the .info file.
NB: Project tests are still failing due to cached dependencies: https://drupal.org/project/pm/testing-status
I'm going to give this some more time before trying to get some help to refresh them.
Comment #33
juliangb CreditAttribution: juliangb commentedOpened issue #2059443: Rebuild Project Management 7.x-1.x dependencies to try to get the testing issue fixed.
Comment #34
juliangb CreditAttribution: juliangb commentedProject tests issue is fixed, so test results are through. This patch no longer applies unfortunately as reported in #31.
Comment #35
D34dMan CreditAttribution: D34dMan commentedSince this was unassigned, i take up the task.
I apologize for not going through the issue queue before working on this. I had totally forgotten this. ( In my defense i was working without internet access).
Points to be noted.
Introduced dependency on:
1.) Addressfield
2.) email
3.) Link
Discussions welcomed.
Note for testers:
This one has Pmperson as well as PMTeam migration patch too.
Test everything except Permission.
Comment #36
D34dMan CreditAttribution: D34dMan commentedComment #38
D34dMan CreditAttribution: D34dMan commentedRerolling against latest 7.x-1.x
Comment #40
D34dMan CreditAttribution: D34dMan commentedThere was a stupid (me) bug introduced by me to check hook_requirements in the previous patch. Have been removed. The Test bot wont be happy. But the patch is "testable"
Comment #42
juliangb CreditAttribution: juliangb commentedI'd suggest we commit the relevant dependencies to 7.x-1.x so that the testbots can be happy - that will speed our own reviews.
Comment #43
juliangb CreditAttribution: juliangb commentedHere's a functional review based on testing the patch - not yet read through the latest code:
1. On running update.php, no descriptions are shown for any of the 3 updates due to be run (I thought these were there before).
2. I don't think the customer provider, and active flags should be in a single field - they are quite different so I think they should be separate. I think active should be a separate yes/no.
3. Could the human name of the fields not be prefixed with "Organization"? That should help with sharing fields across content types where possible, which then helps with views etc.
4. Could the order of the fields (in the edit view) be the same as before? Name should be top, note should be bottom.
Comment #44
juliangb CreditAttribution: juliangb commentedFurther testing of this, I got some issues where looking at other node content types having done this migration caused errors to come up. The reason was that the pmorganization table didn't exist anymore.
Comment #45
D34dMan CreditAttribution: D34dMan commentedIt is there, they are all collpased under a fieldset.
Those three looked like "tags" or flags to me. My thoughts was the user being able to add more tags just by adding more entries in the field definitions. For example "Premier Customer", "Archived", "Offshore" or anything else could be added to the multiple select list. This means no need to add "more" fields to the content type.
So the reason i collected them in on field is cause their "behaviour" was similar even though their context was not. Arguably sometimes you would want just binary filter ( On or Off state of Active (tag?) ) to be available as view filter. Keeping the Active filed separate would be more convenient in this case.
Also some might never want to use "Provider/Customer" context at all. In this case instead of deleting a field, they can just configure/edit the multiple select list.
Please consider my thoughts on it, and lemme know what to do with that field ( break it into two or keep it as such ).
yes, good idea.
I had tried to keep it that way. Sorry for the in-discrepancy.
Yes, things are hardcoded in other "dependent" modules. Will remove them as i work on it.
Comment #46
juliangb CreditAttribution: juliangb commentedI'll test update descriptions again. They were definitely missing when I expanded the fieldset, not sure why.
Flags/tags - i'm open to different views, but it sounds like being able to do a binary filter would be helpful.
By the way, is it most helpful for me to continually test the feature/pmperson branch providing frequent comments on anything I see - is there anything else that would be helpful for me to do?
Comment #47
D34dMan CreditAttribution: D34dMan commentedPlease go ahead and do the testing, whichever way you feel good about it. I understand things have broken for all the submodules due to hardcoded dependency on pmorganization table. I would like to turn a blind eye on that in features/pmperson branch right now. Those will eventually be fixed when i work on their migration.
@juliangb, i have been doing a local testing to ensure it works. Most of our reviews/feedbacks are based on how its implemented. This i feel could be decided before i actually start working on it.
For example:
If i get a list of all the fields that need to be ported ( along with the field name and type ). I could get it correct the first time. Otherwise its ok too. Slow and steady wins the race.
Comment #48
juliangb CreditAttribution: juliangb commentedOK, I will continue to test pmperson, pmteam and pmorganization only for now.
Good point on anything that we can do to avoid doing things multiple times. Perhaps we should have a general rule that given the immense nature of these changes we will try to mimic the existing custom fields as much as possible with the field api, and then if anything doesn't make sense, open an issue to potentially change later (for example, the realisation that teams can contain organisations, which doesn't make sense to me). That way we should keep the reviews relatively technical only.
Comment #49
juliangb CreditAttribution: juliangb commentedBy the way, I committed the necessary dependencies to 7.x-1.x, so once the -dev releases regenerate these tests should pass.
Comment #50
D34dMan CreditAttribution: D34dMan commentedWill be creating a user reference field (entityreference) on pmorganization that would hold info about the user that belongs to the organization. Relevant discussion in #1412134-32: Change from Project Management Persons to Drupal Users and #2115545-13: Recursive Field for Drupal PM.
Comment #51
juliangb CreditAttribution: juliangb commentedAdd link to parent issue.
Comment #52
juliangb CreditAttribution: juliangb commented@D34dMan
On line 168 of pmorganization/includes/pmorganization.migrate.inc there is a reference to an undefined variable $oid.
Comment #53
D34dMan CreditAttribution: D34dMan commentedFixed issue in #52 in features/pmperson branch.
Comment #54
juliangb CreditAttribution: juliangb commentedWe may have discussed this previously (if so, I apologise), but could we quickly run through the functionality provided by the organization members field? A summary of what it replaces, and anything it drives would help me review.
Comment #56
D34dMan CreditAttribution: D34dMan commentedthe field replaces the way we associate Drupal user with organizations.
Old case of 7.x-1.x
1) We had an intermediate entity called pmperson which had information regarding Drupal User as well as the associated organization.
2) We had been injecting (duplicated information) the organization id into user profile to handle permissions.
In 7.x-2.x,
1.) Intermediate entity absent.
2.) Drupal user is associated with the organization through, the 'Organization Members' field in pmorganization.
3.) Permission architecture has been changed. No longer needs to inject Organization info into user profiles.
4.) User can belong to multiple organizations now ( not tested, but supported in architecture ).
Comment #60
juliangb CreditAttribution: juliangb commentedDone (near enough). Remaining tasks will be created as separate issues.