[ckan-changes] commit/ckan: kindly: [authz] redo migration to groups

Bitbucket commits-noreply at bitbucket.org
Thu Jun 23 13:58:29 UTC 2011


1 new changeset in ckan:

http://bitbucket.org/okfn/ckan/changeset/87356ad5df9f/
changeset:   87356ad5df9f
branch:      feature-1094-authz
user:        kindly
date:        2011-06-23 15:58:11
summary:     [authz] redo migration to groups
affected #:  3 files (2.5 KB)

--- a/ckan/migration/versions/040_add_user_group_tables.py	Thu Jun 23 11:29:48 2011 +0100
+++ b/ckan/migration/versions/040_add_user_group_tables.py	Thu Jun 23 14:58:11 2011 +0100
@@ -1,67 +1,34 @@
 from migrate import *
 
 def upgrade(migrate_engine):
-
     migrate_engine.execute('''
-
-BEGIN;
-
-CREATE TABLE user_group (
-	id text NOT NULL,
-	name text NOT NULL,
-	parent_id text
+CREATE TABLE "member" (
+    id text NOT NULL,
+    user_id text,
+    group_id text,
+    capacity text
 );
 
-CREATE TABLE user_group_extra (
-	id text NOT NULL,
-	user_group_id text NOT NULL,
-	"key" text NOT NULL,
-	"value" text NOT NULL
-);
+ALTER TABLE "group"
+    ADD COLUMN parent_id text;
 
-CREATE TABLE user_group_package (
-	id text NOT NULL,
-	user_group_id text NOT NULL,
-	package_id text NOT NULL,
-	capacity text
-);
+ALTER TABLE group_revision
+    ADD COLUMN parent_id text;
 
-CREATE TABLE user_group_user (
-	id text NOT NULL,
-	user_group_id text NOT NULL,
-	user_id text NOT NULL,
-	capacity text
-);
+ALTER TABLE package_group
+    ADD COLUMN capacity text,
+    ADD COLUMN type text;
 
+ALTER TABLE package_group_revision
+    ADD COLUMN capacity text,
+    ADD COLUMN type text;
 
-ALTER TABLE user_group
-	ADD CONSTRAINT user_group_pkey PRIMARY KEY (id);
+ALTER TABLE "member"
+    ADD CONSTRAINT member_pkey PRIMARY KEY (id);
 
-ALTER TABLE user_group_extra
-	ADD CONSTRAINT user_group_extra_pkey PRIMARY KEY (id);
+ALTER TABLE "member"
+    ADD CONSTRAINT member_group_id_fkey FOREIGN KEY (group_id) REFERENCES "group"(id);
 
-ALTER TABLE user_group_package
-	ADD CONSTRAINT user_group_package_pkey PRIMARY KEY (id);
-
-ALTER TABLE user_group_user
-	ADD CONSTRAINT user_group_user_pkey PRIMARY KEY (id);
-
-
-
-ALTER TABLE user_group_extra
-	ADD CONSTRAINT user_group_extra_user_group_id_fkey FOREIGN KEY (user_group_id) REFERENCES user_group(id);
-
-ALTER TABLE user_group_package
-	ADD CONSTRAINT user_group_package_package_id_fkey FOREIGN KEY (package_id) REFERENCES package(id);
-
-ALTER TABLE user_group_package
-	ADD CONSTRAINT user_group_package_user_group_id_fkey FOREIGN KEY (user_group_id) REFERENCES user_group(id);
-
-ALTER TABLE user_group_user
-	ADD CONSTRAINT user_group_user_user_group_id_fkey FOREIGN KEY (user_group_id) REFERENCES user_group(id);
-
-ALTER TABLE user_group_user
-	ADD CONSTRAINT user_group_user_user_id_fkey FOREIGN KEY (user_id) REFERENCES "user"(id);
-
-COMMIT;
+ALTER TABLE "member"
+    ADD CONSTRAINT member_user_id_fkey FOREIGN KEY (user_id) REFERENCES "user"(id);
 ''')


--- a/ckan/model/authz.py	Thu Jun 23 11:29:48 2011 +0100
+++ b/ckan/model/authz.py	Thu Jun 23 14:58:11 2011 +0100
@@ -100,38 +100,6 @@
            Column('role', UnicodeText)
            )
 
-user_group_table = Table(
-           'user_group', metadata,
-           Column('id', UnicodeText, primary_key=True, default=make_uuid),
-           Column('name', UnicodeText, nullable=False),
-           Column('parent_id', UnicodeText, nullable=True),
-)
-
-user_group_extra_table = Table(
-           'user_group_extra', metadata,
-           Column('id', UnicodeText, primary_key=True, default=make_uuid),
-           Column('user_group_id', UnicodeText, ForeignKey('user_group.id'), nullable=False),
-           Column('key', UnicodeText, nullable=False),
-           Column('value', UnicodeText, nullable=False),
-)
-
-user_group_user_table = Table(
-           'user_group_user', metadata,
-           Column('id', UnicodeText, primary_key=True, default=make_uuid),
-           Column('user_group_id', UnicodeText, ForeignKey('user_group.id'), nullable=False),
-           Column('user_id', UnicodeText, ForeignKey('user.id'), nullable=False),
-           Column('capacity', UnicodeText),
-)
-
-user_group_package_table = Table(
-           'user_group_package', metadata,
-           Column('id', UnicodeText, primary_key=True, default=make_uuid),
-           Column('user_group_id', UnicodeText, ForeignKey('user_group.id'), nullable=False),
-           Column('package_id', UnicodeText, ForeignKey('package.id'), nullable=False),
-           Column('capacity', UnicodeText),
-)
-
-
 
 class RoleAction(DomainObject):
     def __repr__(self):


--- a/ckan/model/group.py	Thu Jun 23 11:29:48 2011 +0100
+++ b/ckan/model/group.py	Thu Jun 23 14:58:11 2011 +0100
@@ -14,10 +14,19 @@
            'PackageGroup', 'GroupRevision', 'PackageGroupRevision',
            'package_group_revision_table']
 
+user_group_table = Table('member', metadata,
+    Column('id', UnicodeText, primary_key=True, default=make_uuid),
+    Column('user_id', UnicodeText, ForeignKey('user.id')),
+    Column('group_id', UnicodeText, ForeignKey('group.id')),
+    Column('capacity', UnicodeText),
+    )
+
 package_group_table = Table('package_group', metadata,
     Column('id', UnicodeText, primary_key=True, default=make_uuid),
     Column('package_id', UnicodeText, ForeignKey('package.id')),
     Column('group_id', UnicodeText, ForeignKey('group.id')),
+    Column('capacity', UnicodeText),
+    Column('type', UnicodeText),
     )
     
 vdm.sqlalchemy.make_table_stateful(package_group_table)
@@ -29,6 +38,7 @@
     Column('title', UnicodeText),
     Column('description', UnicodeText),
     Column('created', DateTime, default=datetime.now),
+    Column('parent_id', UnicodeText),
     )
 
 vdm.sqlalchemy.make_table_stateful(group_table)

Repository URL: https://bitbucket.org/okfn/ckan/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list