tareq1988 / wp-eloquent

Eloquent ORM for WordPress
https://tareq.co/2015/05/eloquent-orm-in-wordpress/
566 stars 135 forks source link

How Do I Create (Drop) Tables For Custom Models In The Database? #72

Open phylogram opened 4 years ago

phylogram commented 4 years ago

When I create new tables, I usually would create them with a register_activation_hook hook and callback and drop them with register_deactivation_hook … How can I make sure the tables for custom models are going to be created at activation and dropped with the deactivation of my plugin?

Thanks for this repository by the way! Really made things more flexible, then the usual WP_Query search!

tareq1988 commented 4 years ago

I guess you've to create the tables with WPDB class, or you can run through the ORM. Basically this library builds the query via Eloquent and runs via $wpdb. Using ORM is always slower. This library doesn't act like Laravel migrations. So you should create the tables usually you do.