Changeset 87
- Timestamp:
- 10/15/07 15:32:02 (15 months ago)
- Files:
-
- 1 modified
-
django/trunk/contrib/evolve.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
django/trunk/contrib/evolve.py
r85 r87 23 23 self.name = self.getTableName(lines[0]) 24 24 self.old_fields = {} 25 for line in lines[1:-1]: 25 for line in lines[1:-1]: # remove create table and closing bracket 26 26 line = line.strip().strip(',') 27 27 self.old_fields[self.getFieldName(line)] = line … … 29 29 30 30 def new(self, sql): 31 self.new_fields = [line.strip().strip(',') for line in sql.splitlines()[ 2:-1]]31 self.new_fields = [line.strip().strip(',') for line in sql.splitlines()[1:-1]] # remove create table and closing bracket 32 32 33 33 def getTableName(self, sql): … … 88 88 89 89 if __name__=='__main__': 90 new_tables_sql = os.popen('manage.py sql %s' % app).read() .split(';')[1:-2]91 old_tables_sql = os.popen('sqlite3 %s ".schema %s_%%"' % (database, app)).read() .split(';')[:-1]90 new_tables_sql = os.popen('manage.py sql %s' % app).read() 91 old_tables_sql = os.popen('sqlite3 %s ".schema %s_%%"' % (database, app)).read() 92 92 93 # remove control characters 94 ctrl = re.compile(r'[\000-\011\013-\037]') 95 new_tables_sql = ctrl.sub('', new_tables_sql) 96 old_tables_sql = ctrl.sub('', old_tables_sql) 97 98 new_tables_sql = new_tables_sql.split(';')[1:-2] # remove begin, commit and empty ; at the end 99 old_tables_sql = old_tables_sql.split(';')[:-1] # remove empty ; at the end 100 93 101 tables = {} 94 102 … … 99 107 for sql in new_tables_sql: 100 108 t = Table(sql.strip()) 101 tables[t.name].new(sql )109 tables[t.name].new(sql.strip()) 102 110 103 111 for table in tables.values():