FormMeta.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. class NF_Database_Migrations_FormMeta extends NF_Abstracts_Migration
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct(
  7. 'nf3_form_meta',
  8. 'nf_migration_create_table_form_meta'
  9. );
  10. }
  11. public function run()
  12. {
  13. $query = "CREATE TABLE IF NOT EXISTS {$this->table_name()} (
  14. `id` int NOT NULL AUTO_INCREMENT,
  15. `parent_id` int NOT NULL,
  16. `key` longtext NOT NULL,
  17. `value` longtext,
  18. `meta_key` longtext,
  19. `meta_value` longtext,
  20. UNIQUE KEY (`id`)
  21. ) {$this->charset_collate()};";
  22. dbDelta( $query );
  23. }
  24. /**
  25. * Function to run our stage one upgrades.
  26. */
  27. public function do_stage_one()
  28. {
  29. $query = "ALTER TABLE {$this->table_name()}
  30. ADD `meta_key` longtext {$this->collate()},
  31. ADD `meta_value` longtext {$this->collate()}";
  32. global $wpdb;
  33. $wpdb->query( $query );
  34. }
  35. }