Source

jp-reading-alt / src / migrations / 0001_initial.py

Full commit
# -*- coding: utf-8 -*-

from south.db import db
from django.db import models, get_model
from django.conf import settings

ALTERNATION_TYPES = (
        ('/', 'root node'),
        ('k', 'kanji node'),
        ('b', 'base reading'),
        ('v', 'vowel length'),
        ('s', 'sequential voicing'),
        ('g', 'sound euphony'),      # Note: lumped together with 's'
        ('p', 'palatalization'),
        ('G', 'graphical similarity'),
        ('S', 'semantic similarity'),
        ('c', 'cooccurrence'),
    )

class Migration:
    
    def forwards(self):
        
        # Model 'ReadingAlternation'
        db.create_table('jp_reading_alt_readingalternation', (
            ('left_visit', models.IntegerField(primary_key=True)),
            ('right_visit', models.IntegerField(db_index=True)),
            ('value', models.CharField(
                max_length=settings.MAX_READING_LENGTH * \
                settings.UTF8_BYTES_PER_CHAR)),
            ('code', models.CharField(max_length=1, choices=ALTERNATION_TYPES)),
            ('probability', models.FloatField()),
        ))
        # Model 'KanjiReading'
        db.create_table('jp_reading_alt_kanjireading', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('reading', models.CharField(
                max_length=settings.MAX_READING_LENGTH * \
                        settings.UTF8_BYTES_PER_CHAR,
                db_index=True,
                help_text='The reading of this kanji.',
            )),
            ('kanji', models.CharField( max_length=settings.UTF8_BYTES_PER_CHAR, help_text='The kanji from which the reading derived.', )),
            ('alternations', models.CharField(max_length=len(ALTERNATION_TYPES), blank=True, null=True, help_text='The alternation codes used to get this reading.')),
            ('probability', models.FloatField( help_text='The log-probability of this reading for this kanji.')),
            ('reading_alternation', models.ForeignKey(
                get_model('jp_reading_alt', 'readingalternation'),
                blank=True, null=True,
                help_text='The final alternation step which' \
            ' provided this reading.')),
        ))
        
        db.send_create_signal('jp_reading_alt', ['ReadingAlternation','KanjiReading'])
    
    def backwards(self):
        db.delete_table('jp_reading_alt_kanjireading')
        db.delete_table('jp_reading_alt_readingalternation')