soflyy / oxygen-bugs-and-features

Bug Reports & Feature Requests for Oxygen
https://oxygenbuilder.com/
314 stars 29 forks source link

Oxygen specific database tables #1308

Open mayankguptadotcom opened 4 years ago

mayankguptadotcom commented 4 years ago

Describe the feature you'd like to see included in Oxygen. As a oxygen site developer, I would like oxygen related data (templates, settings) to be stored in separate database tables so that syncing the templates between different environments becomes easy.

A clear, detailed description of the feature you're requesting. During development, it's far more easier to just replace or sync certain database tables rather than replacing wp_options tables or wp_posts & post_meta tables and excluding templates, or plugin specific site settings. I guess, there should be a way to push or pull templates and oxygen settings between two different environments.

What are the use cases for this feature? Development flow would become far more easier.

wpsumo commented 4 years ago

+1 Better and faster with dedicated index. Easier push and pull from staging to production by only pushing new design sets without facing issue with other post data.

deb85 commented 1 year ago

You'd need at least an equivalent of wp_posts and wp_postmeta, which could be oxy_templates and oxy_templatesmeta, and probably hook on to some filters to change the SQL query for the specific post_type.

You could then have an equivalent table of wp_options just for oxygen, like oxy_options, and filter the output of get_option to change the SQL query towards the specific table for options starting with some prefix related with oxygen.

The plugin cpt-tables seems to be doing something similar (haven't had chance to try it). From what I've read, this plugin stores data of custom post_types in their own table, but also leaves an empty row on wp_posts table with just the type and id. (This is probably necessary for the custom types to be indexable with the rest of posts.) This is more conveniently organized, but still there is a relation that might complicate migrations. This plugin might be enough for what you're looking, if not a good starting point for implement simething similar.

The thing about custom tables is you can't query them like posts, or use regular functions get_post or get_post_meta or have revisions. I thought to remember it was possible to instantiate WP_Query with your custom tables, but it seems not, and I haven't found anything in the codex (only this).

Another hassle is you would have to be compatible with previous versions of oxygen, and offer some way to switch and migrate from one method to the other. Not sure if the added complexity would be worth it, but I agree that separating oxygen templates (and settings?) into their own table would make migrations easier.