2013-12-18 13:32:13 +00:00
|
|
|
from pokedex.db import metadata
|
|
|
|
|
|
|
|
### Helper functions for oracle
|
|
|
|
def rewrite_long_table_names():
|
2014-02-21 22:59:52 +00:00
|
|
|
"""Disemvowels all table names over thirty characters."""
|
2014-02-21 21:45:47 +00:00
|
|
|
# Load tables from metadata
|
|
|
|
table_objs = metadata.tables.values()
|
2013-12-18 13:32:13 +00:00
|
|
|
|
|
|
|
# Shorten table names, Oracle limits table and column names to 30 chars
|
|
|
|
for table in table_objs:
|
2014-02-21 21:45:47 +00:00
|
|
|
table._original_name = table.name
|
2013-12-18 13:32:13 +00:00
|
|
|
|
2014-02-21 21:45:47 +00:00
|
|
|
if len(table.name) > 30:
|
|
|
|
for letter in 'aeiouy':
|
|
|
|
table.name = table.name.replace(letter, '')
|
2013-12-18 13:32:13 +00:00
|
|
|
|
2014-02-21 21:45:47 +00:00
|
|
|
def restore_long_table_names():
|
|
|
|
"""Modifies the table names to restore the long-naming."""
|
2013-12-18 13:32:13 +00:00
|
|
|
for table in metadata.tables.values():
|
2014-02-21 21:45:47 +00:00
|
|
|
table.name = table._original_name
|
|
|
|
del table._original_name
|