Changes between Initial Version and Version 1 of Ticket #23541
- Timestamp:
- Sep 22, 2014, 9:24:41 PM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #23541 – Description
initial v1 3 3 1. Install this function at a shell for PostgreSQL 4 4 5 ```CREATE FUNCTION exec(text) returns text language plpgsql volatile5 {{{CREATE FUNCTION exec(text) returns text language plpgsql volatile 6 6 AS $f$ 7 7 BEGIN … … 9 9 RETURN $1; 10 10 END; 11 $f$; ```11 $f$;}}} 12 12 13 13 source: http://wiki.postgresql.org/wiki/Dynamic_DDL … … 15 15 2. Write a RunSQL operation to help rename some tables 16 16 17 ```class Migration(migrations.Migration):17 {{{class Migration(migrations.Migration): 18 18 ... 19 19 operations = [ … … 24 24 sql="""select exec(format('alter table %I rename to %I', tablename, regexp_replace(tablename, '^hello, 'goodbye'))) from pg_tables where tablename like 'hello%';""" 25 25 ), 26 ]``` 26 ] 27 ...}}} 27 28 28 29 3. Run the migration. I got this error: 29 30 30 ```Traceback (most recent call last):31 {{{Traceback (most recent call last): 31 32 File "./manage.py", line 10, in <module> 32 33 execute_from_command_line(sys.argv) … … 55 56 File "/Users/abhillman/stable_env/lib/python2.7/site-packages/django/db/backends/utils.py", line 65, in execute 56 57 return self.cursor.execute(sql, params) 57 IndexError: list index out of range ```58 IndexError: list index out of range}}} 58 59 59 Not sure what's going on here. Could it be the custom function?60 Not sure what's going on here. Could it be the custom PGSQL function?