antipode3141592 / RACC_Stripe

Stripe Integration with shortcodes for RACC
MIT License
0 stars 0 forks source link

Add db create/update functions to plugin activation #28

Open antipode3141592 opened 6 years ago

antipode3141592 commented 6 years ago

Instead of manually editing the database by hand, utilize WP's plugin activation hooks to add/update tables/procedures/views(eventually) to the db automatically. this shall reduce issues when updating the plugin and make it easier to maintain when developing between local/test/live platforms.

antipode3141592 commented 6 years ago

Added a function that adds tables and stored procedures upon plugin activation. there isn't an easy way to delete the tables (and we might want that data later) upon plugin uninstall, so that probably won't be implemented. the table additions use the wordpress dbDelta() function, which checks for existence and inserts or updates the table.
for the stored procedures, dbDelta() was failing (it parses the input in a very specific manner, geared towards tables), so I used $wpdb-query() to create the stored procedures with an explicit CREATE PROCEDURE command, so this will need some code for updating a previously existing stored procedure. currently, best option for creating tables/procedures cleanly is by: 1) deactivate plugin 2) drop all relevant tables and procedures 3) update codebase of plugin 4) activate plugin

antipode3141592 commented 5 years ago

-Added a db version check routine so that the db install scripts only fire when the database version has been updated. -Still need to address stored procedure updating