Forms.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. class NF_Database_Migrations_Forms extends NF_Abstracts_Migration
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct(
  7. 'nf3_forms',
  8. 'nf_migration_create_table_forms'
  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. `title` longtext,
  16. `key` longtext,
  17. `created_at` TIMESTAMP,
  18. `updated_at` DATETIME,
  19. `views` int(11),
  20. `subs` int(11),
  21. `form_title` longtext,
  22. `default_label_pos` varchar(15),
  23. `show_title` bit,
  24. `clear_complete` bit,
  25. `hide_complete` bit,
  26. `logged_in` bit,
  27. `seq_num` int,
  28. UNIQUE KEY (`id`)
  29. ) {$this->charset_collate()};";
  30. dbDelta( $query );
  31. }
  32. /**
  33. * Function to run our stage one upgrades.
  34. */
  35. public function do_stage_one()
  36. {
  37. /**
  38. * TODO:
  39. *
  40. DROP `key`,
  41. DROP `views`,
  42. DROP `subs`,
  43. *
  44. */
  45. $query = "ALTER TABLE {$this->table_name()}
  46. ADD `form_title` longtext {$this->collate()},
  47. ADD `default_label_pos` varchar(15) {$this->collate()},
  48. ADD `show_title` bit,
  49. ADD `clear_complete` bit,
  50. ADD `hide_complete` bit,
  51. ADD `logged_in` bit,
  52. ADD `seq_num` int";
  53. global $wpdb;
  54. $wpdb->query( $query );
  55. }
  56. }