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.)

  1. country to pmorganization_country (select list)
  2. orglanguage to pmorganization_language (select list)
  3. provstate to pmorganization_provstate (text field)
  4. city to pmorganization_city (text field)
  5. zip to pmorganization_zip (text field)
  6. address to pmorganization_address (textarea)
  7. taxid to pmorganization_taxid (text field)
  8. email to pmorganization_email (text field)
  9. www to pmorganization_www (text field)
  10. phone to pmorganization_phone (text field)
  11. currency to pmorganization_currency (select list)
  12. iscustomer to pmorganization_iscustomer (check box)
  13. isprovider to pmorganization_isprovider (check box)
  14. isactive to pmorganization_isactive (check box)
  15. pricemode to pmorganization_pricemode (select list)
  16. price to pmorganization_price (text field)
  17. body to body (migration code pending)

Fields needed to be declared by not used.

  1. pmorganization_id

Points to be discussed:

  1. Use of address field.
  2. Use of email field
  3. Use of phone field
  4. Use of link field
  5. 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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Raphael Dürst’s picture

Title: PMOrgnaization: Migrate to field_api based fields. » PMOrganization: Migrate to field_api based fields.

Aren'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.

D34dMan’s picture

Nice idea, can you please list the fields so we could discuss regarding the list, what goes into pm and what doesn't.

Raphael Dürst’s picture

I made a list with all fields which occur in more than one pm module:

  • pricemode (organization/project/task/ticket)
  • price (organization/project/task/ticket)
  • currency (organization/project/task/ticket)
  • datebegin (project/task/ticket)
  • dateend (project/task/ticket)
  • durationunit (project/task/ticket)
  • duration (project/task/ticket) (also timetracking, but not exactly the same)
  • billable (project/task/ticket/timetracking/expense)
  • billed (project/task/ticket/timetracking/expense)
  • email (organization/project)
  • www (organization/project)
  • phone (organization/project)
  • assigned_nid (project/task/ticket)
  • assigned_title (project/task/ticket)
  • amount
  • tax1 (expense/invoice)
  • tax2 (expense/invoice)
  • total (expense/invoice)

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).

juliangb’s picture

Could 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.

Raphael Dürst’s picture

I 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.

D34dMan’s picture

or we can have a micro patch for pmorganization, pmtask and pmticket ( just the reference field ) and then do a mega patch for pmnote.

juliangb’s picture

#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.

Raphael Dürst’s picture

Ok, 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?

D34dMan’s picture

Assigned: D34dMan » Unassigned

I 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.

Raphael Dürst’s picture

Status: Active » Needs review
FileSize
943 bytes

I 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

D34dMan’s picture

I 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.

Raphael Dürst’s picture

Yes, 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.

Status: Needs review » Needs work

The last submitted patch, 2041659-pmorganization_ref.patch, failed testing.

Raphael Dürst’s picture

Status: Needs work » Needs review
FileSize
2.22 KB

The 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.

Status: Needs review » Needs work

The last submitted patch, 2041659-pmorganization_ref-13.patch, failed testing.

Raphael Dürst’s picture

Strange, if I run the tests on my local installation, they pass the tests.
I don't know what's causing the tests to fail...

juliangb’s picture

Status: Needs work » Needs review

This 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.

dbt102’s picture

Status: Needs review » Needs work

I 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...

juliangb’s picture

@dbt102 Could you try git apply -v [filename]? It will give more details about whether it was ok or not.

Raphael Dürst’s picture

Status: Needs work » Needs review
FileSize
61.32 KB
1.43 KB

Ok, I removed the entityreference from setUp() in the tests and ran them again.

They all passed with this patch.

Screen Shot 2013-07-17 at 2.29.42 PM.png

Status: Needs review » Needs work

The last submitted patch, 2041659-pmorganization_ref-17.patch, failed testing.

dbt102’s picture

Had 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

Raphael Dürst’s picture

This 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.

dbt102’s picture

OK ... Thanks ... I see them all

D34dMan’s picture

+dependencies[] = entityreference

Will have to modify testcase to enable entityreference. Otherwise it will always fail. This applies to pmtask and pmticket as well.

D34dMan’s picture

entityreference, entity and ctools to be precise.

Raphael Dürst’s picture

As 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.

juliangb’s picture

I 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.

Raphael Dürst’s picture

I 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:

$instance = array(
  'field_name' => 'pmorganization_ref',
  'entity_type' => 'node',
  'bundle' => 'pmproject',
  'label' => 'Organization NID',
  'widget' => array(
    'type' => 'options_select'
  )
);
field_create_instance($instance);
Raphael Dürst’s picture

Status: Needs work » Needs review
dbt102’s picture

Patch 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...

juliangb’s picture

Status: Needs review » Needs work

This 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.

juliangb’s picture

Opened issue #2059443: Rebuild Project Management 7.x-1.x dependencies to try to get the testing issue fixed.

juliangb’s picture

Project tests issue is fixed, so test results are through. This patch no longer applies unfortunately as reported in #31.

D34dMan’s picture

Since 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.

D34dMan’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 35: issue-2041659-pmorganization-migrate.patch, failed testing.

D34dMan’s picture

Status: Needs work » Needs review
FileSize
166.06 KB

Rerolling against latest 7.x-1.x

Status: Needs review » Needs work

The last submitted patch, 38: issue-2041659-38-pmorganization-migrate-rerolled.patch, failed testing.

D34dMan’s picture

Status: Needs work » Needs review
FileSize
166.05 KB

There 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"

Status: Needs review » Needs work

The last submitted patch, 40: issue-2041659-39-pmorganization-migrate.patch, failed testing.

juliangb’s picture

I'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.

juliangb’s picture

Here'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.

juliangb’s picture

Further 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.

D34dMan’s picture

On running update.php, no descriptions are shown for any of the 3 updates due to be run (I thought these were there before).

It is there, they are all collpased under a fieldset.

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.

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 ).

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.

yes, good idea.

Could the order of the fields (in the edit view) be the same as before? Name should be top, note should be bottom.

I had tried to keep it that way. Sorry for the in-discrepancy.

Further 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.

Yes, things are hardcoded in other "dependent" modules. Will remove them as i work on it.

juliangb’s picture

I'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?

D34dMan’s picture

Please 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.

FOR: featuers/pmperson branch, status as on Tuesday 8th April 2014.
[pmperson, pmteam, pmorganization] -> Requires Feedback regarding "EVERYTHING" except "PERMISSION"
[pmpersmission] -> work in progress, Don't Test.
[pmproject, pmtask, pmticket, pmnote ...] - Broken, Don't Test.

@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.

juliangb’s picture

OK, 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.

juliangb’s picture

By the way, I committed the necessary dependencies to 7.x-1.x, so once the -dev releases regenerate these tests should pass.

D34dMan’s picture

Will 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.

juliangb’s picture

juliangb’s picture

@D34dMan

On line 168 of pmorganization/includes/pmorganization.migrate.inc there is a reference to an undefined variable $oid.

D34dMan’s picture

Fixed issue in #52 in features/pmperson branch.

juliangb’s picture

We 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.

  • Commit ae9d58c on 7.x-2.x by juliangb:
    Issue #2041659 by D34dMan, Raphael Drst: PMOrganization: Migrate to...
D34dMan’s picture

the 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 ).

  • D34dMan committed 63d2ee9 on 7.x-2.x
    Issue #2041659: "Project Management Organization: access" moved back to...
  • D34dMan committed 7f615ad on 7.x-2.x
    Issue #2041659 by D34dMan, Raphael Drst: PMOrganization: Migrating...

  • D34dMan committed 40c9725 on 7.x-2.x
    Issue #2041659 by D34dMan, juliangb: pmorganization - Migrate old...

  • D34dMan committed 837d077 on 7.x-2.x
    Issue #2041659 by D34dMan, juliangb: pmorganization - Migration of...
juliangb’s picture

Status: Needs work » Fixed

Done (near enough). Remaining tasks will be created as separate issues.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.