comparison roundup/backends/back_postgresql.py @ 2077:3e0961d6d44d

Added the "actor" property. Metakit backend not done (still not confident I know how it's supposed to work ;) Currently it will come up as NULL in the RDBMS backends for older items. The *dbm backends will look up the journal. I hope to remedy the former before 0.7's release. Fixed a bunch of migration issues in the rdbms backends while I was at it (index changes for key prop changes) and simplified the class table update code for RDBMSes that have "alter table" in their command set (ie. not sqlite) ... migration from "version 1" to "version 2" still hasn't actually been tested yet though.
author Richard Jones <richard@users.sourceforge.net>
date Mon, 15 Mar 2004 05:50:20 +0000
parents b1704ba7be41
children c091cacdc505
comparison
equal deleted inserted replaced
2076:2a4309450202 2077:3e0961d6d44d
113 self.cursor.execute('CREATE INDEX otks_key_idx ON otks(otk_key)') 113 self.cursor.execute('CREATE INDEX otks_key_idx ON otks(otk_key)')
114 self.cursor.execute('CREATE TABLE sessions (s_key VARCHAR(255), ' 114 self.cursor.execute('CREATE TABLE sessions (s_key VARCHAR(255), '
115 's_last_use FLOAT(20), s_user VARCHAR(255))') 115 's_last_use FLOAT(20), s_user VARCHAR(255))')
116 self.cursor.execute('CREATE INDEX sessions_key_idx ON sessions(s_key)') 116 self.cursor.execute('CREATE INDEX sessions_key_idx ON sessions(s_key)')
117 117
118 def add_actor_column(self):
119 # update existing tables to have the new actor column
120 tables = self.database_schema['tables']
121 for name in tables.keys():
122 self.cursor.execute('ALTER TABLE _%s add __actor '
123 'VARCHAR(255)'%name)
124
118 def __repr__(self): 125 def __repr__(self):
119 return '<roundpsycopgsql 0x%x>' % id(self) 126 return '<roundpsycopgsql 0x%x>' % id(self)
120 127
121 def sql_stringquote(self, value): 128 def sql_stringquote(self, value):
122 ''' psycopg.QuotedString returns a "buffer" object with the 129 ''' psycopg.QuotedString returns a "buffer" object with the
138 145
139 if __debug__: 146 if __debug__:
140 print >>hyperdb.DEBUG, 'create_class', (self, sql) 147 print >>hyperdb.DEBUG, 'create_class', (self, sql)
141 148
142 self.cursor.execute(sql) 149 self.cursor.execute(sql)
150 self.create_class_table_indexes(spec)
143 return cols, mls 151 return cols, mls
144 152
145 def create_journal_table(self, spec): 153 def create_journal_table(self, spec):
146 cols = ',' . join(['"%s" VARCHAR(255)' % x 154 cols = ',' . join(['"%s" VARCHAR(255)' % x
147 for x in 'nodeid date tag action params' . split()]) 155 for x in 'nodeid date tag action params' . split()])
149 157
150 if __debug__: 158 if __debug__:
151 print >>hyperdb.DEBUG, 'create_class', (self, sql) 159 print >>hyperdb.DEBUG, 'create_class', (self, sql)
152 160
153 self.cursor.execute(sql) 161 self.cursor.execute(sql)
162 self.create_journal_table_indexes(spec)
154 163
155 def create_multilink_table(self, spec, ml): 164 def create_multilink_table(self, spec, ml):
156 sql = '''CREATE TABLE "%s_%s" (linkid VARCHAR(255), 165 sql = '''CREATE TABLE "%s_%s" (linkid VARCHAR(255),
157 nodeid VARCHAR(255))''' % (spec.classname, ml) 166 nodeid VARCHAR(255))''' % (spec.classname, ml)
158 167
159 if __debug__: 168 if __debug__:
160 print >>hyperdb.DEBUG, 'create_class', (self, sql) 169 print >>hyperdb.DEBUG, 'create_class', (self, sql)
161 170
162 self.cursor.execute(sql) 171 self.cursor.execute(sql)
172 self.create_multilink_table_indexes(spec, ml)
163 173
164 class Class(rdbms_common.Class): 174 class Class(rdbms_common.Class):
165 pass 175 pass
166 class IssueClass(rdbms_common.IssueClass): 176 class IssueClass(rdbms_common.IssueClass):
167 pass 177 pass

Roundup Issue Tracker: http://roundup-tracker.org/