Change Attribute Type
Permalink
Hi everyone :),
I created a custom Attribute Type and now I would like to change its database schema and add some new columns.
I made the changes in db.xml but I don't know where to tell c5 to refresh my Attribute Type (like you would do it for blocks).
Does anyone knows how to do this?
I created a custom Attribute Type and now I would like to change its database schema and add some new columns.
I made the changes in db.xml but I don't know where to tell c5 to refresh my Attribute Type (like you would do it for blocks).
Does anyone knows how to do this?
If its in a package, you can write upgrade code into the package controller and increment the package version. Add Functionality will then prompt you to click upgrade for the package.
Mmmhhh, it is not in a package. Should I make one? Is it necessary? I don't think I'd have to.
In that case, its not something I have done. With a block the simplest way is to remove it then reinstall the block type. But that also destroys any blocks of that type already created on pages. Maybe the same would work for your attribute.
Another thing you could do is to manually add columns to the table for your attribute using phpMyAdmin, so that the table matches the xml schema. Its what gets done by code in package upgrades, but manually. You just have to be careful to make sure it all matches.
Once I discovered that packages could be upgraded, I started sticking everything in packages, even if they were site specific. It made my development work much easier. This howto may give you some ideas, but is not actually addressing your problemhttp://www.concrete5.org/documentation/how-tos/developers/add-anoth...
Another thing you could do is to manually add columns to the table for your attribute using phpMyAdmin, so that the table matches the xml schema. Its what gets done by code in package upgrades, but manually. You just have to be careful to make sure it all matches.
Once I discovered that packages could be upgraded, I started sticking everything in packages, even if they were site specific. It made my development work much easier. This howto may give you some ideas, but is not actually addressing your problemhttp://www.concrete5.org/documentation/how-tos/developers/add-anoth...
Ok, I didnt want to get my hands dirty(er) messing with the database, buuuut I guess it's the only way.
Thanks John :)
Thanks John :)
Theres still one little thing theat keeps itching me.
Why should concrete5 say this if it is not possible to update an attribute type?
http://www.concrete5.org/documentation/developers/attributes/types...
"The schema can also be altered later and refreshed through the dashboard."
Why should concrete5 say this if it is not possible to update an attribute type?
http://www.concrete5.org/documentation/developers/attributes/types...
"The schema can also be altered later and refreshed through the dashboard."
Dashboard > Sitewide Settings > Debug > Database Tables and Content > Refresh Databases
I have never worked out just what gets refreshed and updated, and whether tables that have changed get updated by this. So maybe it will help you. Maybe not.
I have never worked out just what gets refreshed and updated, and whether tables that have changed get updated by this. So maybe it will help you. Maybe not.
That might help, I will try and let you know.
(Although im a bit scared for what will happen :D)
(Although im a bit scared for what will happen :D)
I know this is an old thread, but I'm having the same problems.
I also created an custom attribute type and now I need to update it. The db.xml was also changed (added/removed fields).
All is in a package, but how can I update the attribute type itself? The package update routine is the place to insert the code, but how can I update the att.type?
SnefIT
I also created an custom attribute type and now I need to update it. The db.xml was also changed (added/removed fields).
All is in a package, but how can I update the attribute type itself? The package update routine is the place to insert the code, but how can I update the att.type?
SnefIT
If it is in your own package, incrementing the version (1.0.0.1 etc) will cause the package to be on the update list.
Then clicking update will cause c5 to refresh all db.xml in the package.
If you want to do something more complicated, you can add an upgrade() method to run some specific code:
http://www.concrete5.org/documentation/how-tos/developers/add-anoth...
Then clicking update will cause c5 to refresh all db.xml in the package.
If you want to do something more complicated, you can add an upgrade() method to run some specific code:
http://www.concrete5.org/documentation/how-tos/developers/add-anoth...
Thanks!
I already used the package update several times for some updates, but didn't realize that it will handle ALL db.xml files (even the /models/attributes/custom_one/db.xml).
Nice to know! :)
Learning every single day!
SnefIT
I already used the package update several times for some updates, but didn't realize that it will handle ALL db.xml files (even the /models/attributes/custom_one/db.xml).
Nice to know! :)
Learning every single day!
SnefIT