[foundation-web] Properly format schema.sql for MySQL & drop tables first.



commit b02e3d38d520959c0315e89875fcad5b54d21c2d
Author: Bradley M. Kuhn <bkuhn ebb org>
Date:   Wed Dec 18 15:42:09 2013 -0500

    Properly format schema.sql for MySQL & drop tables first.
    
    With this change, schema.sql can be run directly from the mysql command line,
    with a command such as:
        $ mysql -u root -p -D dbname < .../vote/include/schema.sql

 foundation.gnome.org/vote/include/schema.sql |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/foundation.gnome.org/vote/include/schema.sql b/foundation.gnome.org/vote/include/schema.sql
index 3e2ec9a..ec44fb1 100644
--- a/foundation.gnome.org/vote/include/schema.sql
+++ b/foundation.gnome.org/vote/include/schema.sql
@@ -1,3 +1,4 @@
+DROP TABLE IF EXISTS `elections`;
  CREATE TABLE `elections` (
    `id` int(11) NOT NULL auto_increment,
    `type` enum('elections','referendum') NOT NULL default 'elections',
@@ -6,24 +7,27 @@
    `voting_end` datetime default '0000-00-00 00:00:00',
    `choices_nb` int(11) NOT NULL default '0',
    `question` text NOT NULL,
-   PRIMARY KEY  (`id`)
+   PRIMARY KEY  (`id`));
+DROP TABLE IF EXISTS `election_anon_tokens`;
  CREATE TABLE `election_anon_tokens` (
    `id` int(11) NOT NULL auto_increment,
    `anon_token` varchar(200) NOT NULL default '',
    `election_id` int(11) NOT NULL default '0',
    PRIMARY KEY  (`id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=903 DEFAULT CHARSET=utf8
+ ) ENGINE=InnoDB AUTO_INCREMENT=903 DEFAULT CHARSET=utf8;
+DROP TABLE IF EXISTS `election_choices`;
  CREATE TABLE `election_choices` (
    `id` int(11) NOT NULL auto_increment,
    `election_id` int(11) NOT NULL default '0',
    `choice` varchar(150) NOT NULL default '',
    PRIMARY KEY  (`id`)
- ) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 
+ ) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8 ;
+DROP TABLE IF EXISTS `election_tmp_tokens`;
  CREATE TABLE `election_tmp_tokens` (
    `election_id` int(11) NOT NULL default '0',
    `member_id` int(11) NOT NULL default '0',
    `tmp_token` varchar(200) NOT NULL default ''
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 /* 
 from members database we prepare anon tokens
@@ -35,9 +39,10 @@ from members database we prepare anon tokens
  I'm not sure if there's a join done between foundationmembers and the other tables
 */
 
+DROP TABLE IF EXISTS `election_votes`;
 CREATE TABLE `election_votes` (
    `id` int(11) NOT NULL auto_increment,
    `choice_id` int(11) NOT NULL default '0',
    `anon_id` int(11) NOT NULL default '0',
-   PRIMARY KEY  (`id`)
+   PRIMARY KEY  (`id`));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]