Copying event attributes for Calendar v8.2.1 using SQL
Permalink
This is a fairly technical question. In v8.3.0 C5 merged the Calendar plugin into a core feature. I'm trying to figure out the best way to transition from using the Calendar plugin with v8.2.1 to the built in calendar feature in v8.3.0. I see that there are 2 features missing from the core version that were included in the plugin: Priority and an associated express event entity...at least I think these are part of the original plugin. If not please correct me.
I have to figure out how to recreate these features in the calendar feature.
My plan was to add 2 custom attributes to the existing calendar events and write a query to manually copy over the priority and express entity from the old fields to the new attribute fields.
I created the new Express Entity attribute (named choose_express_event) and I see it added to the table as the column
I then run the following query which copies the to the new column
The query works but here's where the trouble comes in. I see the new attribute column contains the copied ids but when, through the site dashboard, I go to the calendar and view an event, the Choose Express Event attribute is unset. If I use the UI to set the attribute I see the new attribute column properly update in the database but if I manually change the database column the UI still lists the previously set attribute. I've tried clearing/turning off the cache with no success.
I've included screenshots to provide clarity.
The 1st image is the original entryID column.
The 2nd image is the new attribute column (see that the copy query worked)
The 3rd image is what I see in the UI after running the query (see that the attribute is unset even though the database attribute column is set)
The 4th image is what I see If I use the UI to set the attribute (see that the database is properly updated).
Does anyone know what I missing to manually set a calendar event custom attribute in the database?
EDIT: After more research it looks like this Priority and EntryID fields are a result of custom code but the spirit of the question remains the same. When I manually update an attribute in the database why don't I see the UI reflect the change?
I have to figure out how to recreate these features in the calendar feature.
My plan was to add 2 custom attributes to the existing calendar events and write a query to manually copy over the priority and express entity from the old fields to the new attribute fields.
I created the new Express Entity attribute (named choose_express_event) and I see it added to the
CalendarEventSearchIndexAttributes
ak_choose_express_event
I then run the following query which copies the
CalendarEvents.eventID
CalendarEventSearchIndexAttributes.ak_choose_express_event
UPDATE CalendarEventSearchIndexAttributes as c SET c.ak_choose_express_event = ( SELECT ce.entryID FROM CalendarEvents as ce WHERE c.eventID = ce.eventID );
The query works but here's where the trouble comes in. I see the new attribute column contains the copied ids but when, through the site dashboard, I go to the calendar and view an event, the Choose Express Event attribute is unset. If I use the UI to set the attribute I see the new attribute column properly update in the database but if I manually change the database column the UI still lists the previously set attribute. I've tried clearing/turning off the cache with no success.
I've included screenshots to provide clarity.
The 1st image is the original entryID column.
The 2nd image is the new attribute column (see that the copy query worked)
The 3rd image is what I see in the UI after running the query (see that the attribute is unset even though the database attribute column is set)
The 4th image is what I see If I use the UI to set the attribute (see that the database is properly updated).
Does anyone know what I missing to manually set a calendar event custom attribute in the database?
EDIT: After more research it looks like this Priority and EntryID fields are a result of custom code but the spirit of the question remains the same. When I manually update an attribute in the database why don't I see the UI reflect the change?
After more research I find anytime I manually change ANY attribute value (any ak_ column) in the database the site does NOT reflect the change (event after clearing the cache). Is there a separate attributes cache that I'm not aware of?
Have you tried refreshing your entities on the page dashboard/system/environment/entities
Also as an FYI you should really try to do the work using concrete5 core functions instead of manipulating the DB directly, that would ensure that anything attribute wizardry that needs to happen in the background actually does happen.
Refreshing the database entities didn't work. I'll try writing a script to update the entities through core functions instead of sql