Source

bloodhound-mq / t333 / t333_r1427886_mp_gen_schema.diff

The branch 't115_product_env' does not exist.
# HG changeset patch
# Parent 3f53561a2a08f85cf3f0faefca00e18aa899fa13
BH Multiproduct #333 : Generate multi-product DB schema from model meta-data

diff -r 3f53561a2a08 bloodhound_multiproduct/multiproduct/api.py
--- a/bloodhound_multiproduct/multiproduct/api.py	Thu Jan 03 00:36:35 2013 -0500
+++ b/bloodhound_multiproduct/multiproduct/api.py	Thu Jan 03 00:38:12 2013 -0500
@@ -31,7 +31,7 @@
 from trac.util.translation import _, N_
 from trac.web.chrome import ITemplateProvider
 
-from multiproduct.model import Product
+from multiproduct.model import Product, ProductResourceMap
 
 DB_VERSION = 2
 DB_SYSTEM_KEY = 'bloodhound_multi_product_version'
@@ -43,20 +43,9 @@
     implements(IEnvironmentSetupParticipant, ITemplateProvider,
             IPermissionRequestor, ITicketFieldProvider, IResourceManager)
     
-    SCHEMA = [
-        Table('bloodhound_product', key = ['prefix', 'name']) [
-            Column('prefix'),
-            Column('name'),
-            Column('description'),
-            Column('owner'),
-            ],
-        Table('bloodhound_productresourcemap', key = 'id') [
-            Column('id', auto_increment=True),
-            Column('product_id'),
-            Column('resource_type'),
-            Column('resource_id'),
-            ]
-        ]
+    SCHEMA = [modelcls._get_schema() \
+                for modelcls in (Product, ProductResourceMap)]
+    del modelcls
     
     def get_version(self):
         """Finds the current version of the bloodhound database schema"""
diff -r 3f53561a2a08 bloodhound_multiproduct/multiproduct/model.py
--- a/bloodhound_multiproduct/multiproduct/model.py	Thu Jan 03 00:36:35 2013 -0500
+++ b/bloodhound_multiproduct/multiproduct/model.py	Thu Jan 03 00:38:12 2013 -0500
@@ -86,6 +86,7 @@
             'non_key_fields':['product_id','resource_type','resource_id',],
             'no_change_fields':['id',],
             'unique_fields':[],
+            'auto_inc':['id'],
             }
     
     def reparent_resource(self, product=None):