We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Only new fields get the channel_data_field_# tables?

Developer Preview

Brian Litzinger's avatar
Brian Litzinger
693 posts
7 years ago
Brian Litzinger's avatar Brian Litzinger

I upgraded a site and it appears all the old fields still use exp_channel_data, but only new fields use the new schema. This seems a bit confusing… why not just migrate everything to the new format during the upgrade?

       
Seth Barber's avatar
Seth Barber
172 posts
7 years ago
Seth Barber's avatar Seth Barber

We considered migrating all the legacy data into the new structure, but in our tests found that with a moderate number of fields and a moderate number of entries, the update could end up at the PHP timeout threshold. In our testing there isn’t much in the way of performance loss in having data in both structures, so we decided to maintain the legacy data structure at this juncture. We have talked about providing post-upgrade instructions for manually migrating this data.

       
Low's avatar
Low
407 posts
7 years ago
Low's avatar Low

Chiming in for a minute.

Having both options feels like a half-baked solution. For add-ons that target those tables and can’t use the Models (because of intricate queries and whatnot), would now have to support both ways.

I’m sure you’ve all discussed and weighed the pros and cons of the current situation, and in the end the choice is yours to make. But a major version update already is an opportunity to change things drastically, so why not go all the way…?

       
Derek Jones's avatar
Derek Jones
7,561 posts
7 years ago
Derek Jones's avatar Derek Jones

Happy to dive into this more and hear concerns and options, let’s make sure it comes up at the roundtable tomorrow.

FWIW, when Seth says it could easily exceed the PHP timeout, I’ve seen a handful of vanilla ALTER statements take hours to run from the CLI on databases of unextraordinary size. Our thinking is that we’d rather those folks be able to upgrade to v4 and beyond than having to make the choice to be stuck on v3 or move to a host that will let them run MySQL from the command line and potentially bring their site offline for many hours.

       
Brian Litzinger's avatar
Brian Litzinger
693 posts
7 years ago
Brian Litzinger's avatar Brian Litzinger

Low, I don’t know if it helps but in my case I added this to my AppHelper and its made a few things easier and I’ve barely had to change queries:

/**
     * @param $fieldName
     * @return string
     */
    public static function getFieldTableName($fieldName)
    {
        if (self::isEE3()) {
            return ee()->db->dbprefix . 'channel_data';
        }

        $fieldId = str_replace('field_id_', '', $fieldName);
        ee()->db->data_cache = [];
        $fieldTableExists = ee()->db->table_exists('channel_data_field_'. $fieldId);

        // Must be a legacy field in EE4
        if (!$fieldTableExists) {
            return ee()->db->dbprefix . 'channel_data';
        }

        // Looks like a new field in EE4
        return ee()->db->dbprefix.'channel_data_field_' . $fieldId;
    }
       
Brian Litzinger's avatar
Brian Litzinger
693 posts
7 years ago
Brian Litzinger's avatar Brian Litzinger

Actually I suppose that code doesn’t help if you’re fetching a lot of fields at once or have a complicated join.

       
Low's avatar
Low
407 posts
7 years ago
Low's avatar Low

Yeah, will have to do something similar for Low Search’s Field Search filter anyway, regardless of the migration is done fully or not. Doable, but, well, you know.

       
Brian Litzinger's avatar
Brian Litzinger
693 posts
7 years ago
Brian Litzinger's avatar Brian Litzinger

You could also take a more hard line approach. If there is a migration option available from EL after the release, just say that Low Search requires that migration. That way you only have to code for and support 1 method of querying data.

Maybe comparable, but when I released Publisher 2 I said I wasn’t supporting Playa and Matrix anymore and customers had to use the migration to Relationship and Grid tool that EL created. Not once did I get negative feedback, which surprised me. I think customers would be understanding of an extra requirement if you wanted to go that route.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.