Revision: 2950
          https://sourceforge.net/p/mrbs/code/2950/
Author:   cimorrison
Date:     2015-01-17 17:15:27 +0000 (Sat, 17 Jan 2015)
Log Message:
-----------
Created the foreign key.  NOTES!  MySQL only at this stage and the code hasn't 
yet been adapted so all sorts of things could go wrong!  Do not use!

Modified Paths:
--------------
    mrbs/branches/repeat_id_fk/tables.my.sql
    mrbs/branches/repeat_id_fk/web/dbsys.inc

Added Paths:
-----------
    mrbs/branches/repeat_id_fk/web/upgrade/41/
    mrbs/branches/repeat_id_fk/web/upgrade/41/mysql.sql

Modified: mrbs/branches/repeat_id_fk/tables.my.sql
===================================================================
--- mrbs/branches/repeat_id_fk/tables.my.sql    2015-01-17 16:10:45 UTC (rev 
2949)
+++ mrbs/branches/repeat_id_fk/tables.my.sql    2015-01-17 17:15:27 UTC (rev 
2950)
@@ -122,7 +122,7 @@
   start_time     int DEFAULT '0' NOT NULL,
   end_time       int DEFAULT '0' NOT NULL,
   entry_type     int DEFAULT '0' NOT NULL,
-  repeat_id      int DEFAULT '0' NOT NULL,
+  repeat_id      int DEFAULT NULL,
   room_id        int DEFAULT '1' NOT NULL,
   timestamp      timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE 
CURRENT_TIMESTAMP,
   create_by      varchar(80) CHARACTER SET utf8 COLLATE utf8_general_ci 
DEFAULT '' NOT NULL,
@@ -144,6 +144,10 @@
     REFERENCES mrbs_room(id)
     ON UPDATE CASCADE
     ON DELETE RESTRICT,
+  FOREIGN KEY (repeat_id) 
+    REFERENCES mrbs_repeat(id)
+    ON UPDATE CASCADE
+    ON DELETE CASCADE,
   KEY idxStartTime (start_time),
   KEY idxEndTime   (end_time)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Modified: mrbs/branches/repeat_id_fk/web/dbsys.inc
===================================================================
--- mrbs/branches/repeat_id_fk/web/dbsys.inc    2015-01-17 16:10:45 UTC (rev 
2949)
+++ mrbs/branches/repeat_id_fk/web/dbsys.inc    2015-01-17 17:15:27 UTC (rev 
2950)
@@ -24,7 +24,7 @@
 }
 
 
-$db_schema_version = 40;
+$db_schema_version = 41;
 $local_db_schema_version = 1;
 
 // Include the abstraction configured to be used for the default MRBS

Added: mrbs/branches/repeat_id_fk/web/upgrade/41/mysql.sql
===================================================================
--- mrbs/branches/repeat_id_fk/web/upgrade/41/mysql.sql                         
(rev 0)
+++ mrbs/branches/repeat_id_fk/web/upgrade/41/mysql.sql 2015-01-17 17:15:27 UTC 
(rev 2950)
@@ -0,0 +1,19 @@
+# $Id$
+
+# Make mrbs_entry.repeat_id a foreign key
+# Previously repeat_id was set to zero if there was no repeat.
+# However this breaks our foreign key constraint so we have to modify
+# the repeat_id column before we can create the foreign key.
+
+ALTER TABLE %DB_TBL_PREFIX%entry
+  MODIFY COLUMN repeat_id int DEFAULT NULL;
+  
+UPDATE %DB_TBL_PREFIX%entry
+  SET repeat_id=NULL WHERE repeat_id=0;
+
+ALTER TABLE %DB_TBL_PREFIX%entry
+  ADD FOREIGN KEY (repeat_id) 
+    REFERENCES %DB_TBL_PREFIX%repeat(id)
+    ON UPDATE CASCADE
+    ON DELETE CASCADE;
+    
\ No newline at end of file


Property changes on: mrbs/branches/repeat_id_fk/web/upgrade/41/mysql.sql
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to