# encoding: utf-8
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models

class Migration(SchemaMigration):

    def forwards(self, orm):

        # Adding model 'Source'
        db.create_table('places_source', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('module_name', self.gf('django.db.models.fields.CharField')(max_length=128)),
            ('name', self.gf('django.db.models.fields.CharField')(max_length=128)),
            ('last_updated', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)),
        ))
        db.send_create_signal('places', ['Source'])

        # Adding model 'EntityType'
        db.create_table('places_entitytype', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, db_index=True)),
            ('article', self.gf('django.db.models.fields.CharField')(max_length=2)),
            ('verbose_name', self.gf('django.db.models.fields.TextField')()),
            ('verbose_name_plural', self.gf('django.db.models.fields.TextField')()),
            ('show_in_nearby_list', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('show_in_category_list', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('note', self.gf('django.db.models.fields.TextField')(null=True)),
        ))
        db.send_create_signal('places', ['EntityType'])

        # Adding M2M table for field subtype_of on 'EntityType'
        db.create_table('places_entitytype_subtype_of', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('from_entitytype', models.ForeignKey(orm['places.entitytype'], null=False)),
            ('to_entitytype', models.ForeignKey(orm['places.entitytype'], null=False))
        ))
        db.create_unique('places_entitytype_subtype_of', ['from_entitytype_id', 'to_entitytype_id'])

        # Adding M2M table for field subtype_of_completion on 'EntityType'
        db.create_table('places_entitytype_subtype_of_completion', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('from_entitytype', models.ForeignKey(orm['places.entitytype'], null=False)),
            ('to_entitytype', models.ForeignKey(orm['places.entitytype'], null=False))
        ))
        db.create_unique('places_entitytype_subtype_of_completion', ['from_entitytype_id', 'to_entitytype_id'])

        # Adding model 'Identifier'
        db.create_table('places_identifier', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('scheme', self.gf('django.db.models.fields.CharField')(max_length=32)),
            ('value', self.gf('django.db.models.fields.CharField')(max_length=256)),
        ))
        db.send_create_signal('places', ['Identifier'])

        # Adding model 'Entity'
        db.create_table('places_entity', (
            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('title', self.gf('django.db.models.fields.TextField')(blank=True)),
            ('source', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.Source'])),
            ('primary_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.EntityType'], null=True)),
            ('location', self.gf('django.contrib.gis.db.models.fields.PointField')(null=True)),
            ('geometry', self.gf('django.contrib.gis.db.models.fields.GeometryField')(null=True)),
            ('_metadata', self.gf('django.db.models.fields.TextField')(default='{}')),
            ('absolute_url', self.gf('django.db.models.fields.TextField')()),
            ('parent', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['places.Entity'], null=True)),
            ('is_sublocation', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('is_stack', self.gf('django.db.models.fields.BooleanField')(default=False)),
            ('identifier_scheme', self.gf('django.db.models.fields.CharField')(max_length=32)),
            ('identifier_value', self.gf('django.db.models.fields.CharField')(max_length=256)),
        ))
        db.send_create_signal('places', ['Entity'])

        # Adding M2M table for field all_types on 'Entity'
        db.create_table('places_entity_all_types', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('entity', models.ForeignKey(orm['places.entity'], null=False)),
            ('entitytype', models.ForeignKey(orm['places.entitytype'], null=False))
        ))
        db.create_unique('places_entity_all_types', ['entity_id', 'entitytype_id'])

        # Adding M2M table for field all_types_completion on 'Entity'
        db.create_table('places_entity_all_types_completion', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('entity', models.ForeignKey(orm['places.entity'], null=False)),
            ('entitytype', models.ForeignKey(orm['places.entitytype'], null=False))
        ))
        db.create_unique('places_entity_all_types_completion', ['entity_id', 'entitytype_id'])

        # Adding M2M table for field _identifiers on 'Entity'
        db.create_table('places_entity__identifiers', (
            ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)),
            ('entity', models.ForeignKey(orm['places.entity'], null=False)),
            ('identifier', models.ForeignKey(orm['places.identifier'], null=False))
        ))
        db.create_unique('places_entity__identifiers', ['entity_id', 'identifier_id'])


    def backwards(self, orm):

        # Deleting model 'Source'
        db.delete_table('places_source')

        # Deleting model 'EntityType'
        db.delete_table('places_entitytype')

        # Removing M2M table for field subtype_of on 'EntityType'
        db.delete_table('places_entitytype_subtype_of')

        # Removing M2M table for field subtype_of_completion on 'EntityType'
        db.delete_table('places_entitytype_subtype_of_completion')

        # Deleting model 'Identifier'
        db.delete_table('places_identifier')

        # Deleting model 'Entity'
        db.delete_table('places_entity')

        # Removing M2M table for field all_types on 'Entity'
        db.delete_table('places_entity_all_types')

        # Removing M2M table for field all_types_completion on 'Entity'
        db.delete_table('places_entity_all_types_completion')

        # Removing M2M table for field _identifiers on 'Entity'
        db.delete_table('places_entity__identifiers')


    models = {
        'places.entity': {
            'Meta': {'ordering': "('title',)", 'object_name': 'Entity'},
            '_identifiers': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['places.Identifier']", 'symmetrical': 'False'}),
            '_metadata': ('django.db.models.fields.TextField', [], {'default': "'{}'"}),
            'absolute_url': ('django.db.models.fields.TextField', [], {}),
            'all_types': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'entities'", 'blank': 'True', 'to': "orm['places.EntityType']"}),
            'all_types_completion': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'entities_completion'", 'blank': 'True', 'to': "orm['places.EntityType']"}),
            'geometry': ('django.contrib.gis.db.models.fields.GeometryField', [], {'null': 'True'}),
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'identifier_scheme': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
            'identifier_value': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
            'is_stack': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
            'is_sublocation': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
            'location': ('django.contrib.gis.db.models.fields.PointField', [], {'null': 'True'}),
            'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['places.Entity']", 'null': 'True'}),
            'primary_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['places.EntityType']", 'null': 'True'}),
            'source': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['places.Source']"}),
            'title': ('django.db.models.fields.TextField', [], {'blank': 'True'})
        },
        'places.entitytype': {
            'Meta': {'ordering': "('verbose_name',)", 'object_name': 'EntityType'},
            'article': ('django.db.models.fields.CharField', [], {'max_length': '2'}),
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'note': ('django.db.models.fields.TextField', [], {'null': 'True'}),
            'show_in_category_list': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
            'show_in_nearby_list': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
            'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
            'subtype_of': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'subtypes'", 'blank': 'True', 'to': "orm['places.EntityType']"}),
            'subtype_of_completion': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'subtypes_completion'", 'blank': 'True', 'to': "orm['places.EntityType']"}),
            'verbose_name': ('django.db.models.fields.TextField', [], {}),
            'verbose_name_plural': ('django.db.models.fields.TextField', [], {})
        },
        'places.identifier': {
            'Meta': {'object_name': 'Identifier'},
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'scheme': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
            'value': ('django.db.models.fields.CharField', [], {'max_length': '256'})
        },
        'places.source': {
            'Meta': {'object_name': 'Source'},
            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'last_updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
            'module_name': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
            'name': ('django.db.models.fields.CharField', [], {'max_length': '128'})
        }
    }

    complete_apps = ['places']

[((18, 8, 18, 51), 'south.db.db.send_create_signal', 'db.send_create_signal', ({(18, 30, 18, 38): '"""places"""', (18, 40, 18, 50): "['Source']"}, {}), "('places', ['Source'])", False, 'from south.db import db\n'), ((31, 8, 31, 55), 'south.db.db.send_create_signal', 'db.send_create_signal', ({(31, 30, 31, 38): '"""places"""', (31, 40, 31, 54): "['EntityType']"}, {}), "('places', ['EntityType'])", False, 'from south.db import db\n'), ((39, 8, 39, 100), 'south.db.db.create_unique', 'db.create_unique', ({(39, 25, 39, 55): '"""places_entitytype_subtype_of"""', (39, 57, 39, 99): "['from_entitytype_id', 'to_entitytype_id']"}, {}), "('places_entitytype_subtype_of', ['from_entitytype_id',\n    'to_entitytype_id'])", False, 'from south.db import db\n'), ((47, 8, 47, 111), 'south.db.db.create_unique', 'db.create_unique', ({(47, 25, 47, 66): '"""places_entitytype_subtype_of_completion"""', (47, 68, 47, 110): "['from_entitytype_id', 'to_entitytype_id']"}, {}), "('places_entitytype_subtype_of_completion', [\n    'from_entitytype_id', 'to_entitytype_id'])", False, 'from south.db import db\n'), ((55, 8, 55, 55), 'south.db.db.send_create_signal', 'db.send_create_signal', ({(55, 30, 55, 38): '"""places"""', (55, 40, 55, 54): "['Identifier']"}, {}), "('places', ['Identifier'])", False, 'from south.db import db\n'), ((73, 8, 73, 51), 'south.db.db.send_create_signal', 'db.send_create_signal', ({(73, 30, 73, 38): '"""places"""', (73, 40, 73, 50): "['Entity']"}, {}), "('places', ['Entity'])", False, 'from south.db import db\n'), ((81, 8, 81, 83), 'south.db.db.create_unique', 'db.create_unique', ({(81, 25, 81, 50): '"""places_entity_all_types"""', (81, 52, 81, 82): "['entity_id', 'entitytype_id']"}, {}), "('places_entity_all_types', ['entity_id', 'entitytype_id'])", False, 'from south.db import db\n'), ((89, 8, 89, 94), 'south.db.db.create_unique', 'db.create_unique', ({(89, 25, 89, 61): '"""places_entity_all_types_completion"""', (89, 63, 89, 93): "['entity_id', 'entitytype_id']"}, {}), "('places_entity_all_types_completion', ['entity_id',\n    'entitytype_id'])", False, 'from south.db import db\n'), ((97, 8, 97, 86), 'south.db.db.create_unique', 'db.create_unique', ({(97, 25, 97, 53): '"""places_entity__identifiers"""', (97, 55, 97, 85): "['entity_id', 'identifier_id']"}, {}), "('places_entity__identifiers', ['entity_id', 'identifier_id'])", False, 'from south.db import db\n'), ((103, 8, 103, 40), 'south.db.db.delete_table', 'db.delete_table', ({(103, 24, 103, 39): '"""places_source"""'}, {}), "('places_source')", False, 'from south.db import db\n'), ((106, 8, 106, 44), 'south.db.db.delete_table', 'db.delete_table', ({(106, 24, 106, 43): '"""places_entitytype"""'}, {}), "('places_entitytype')", False, 'from south.db import db\n'), ((109, 8, 109, 55), 'south.db.db.delete_table', 'db.delete_table', ({(109, 24, 109, 54): '"""places_entitytype_subtype_of"""'}, {}), "('places_entitytype_subtype_of')", False, 'from south.db import db\n'), ((112, 8, 112, 66), 'south.db.db.delete_table', 'db.delete_table', ({(112, 24, 112, 65): '"""places_entitytype_subtype_of_completion"""'}, {}), "('places_entitytype_subtype_of_completion')", False, 'from south.db import db\n'), ((115, 8, 115, 44), 'south.db.db.delete_table', 'db.delete_table', ({(115, 24, 115, 43): '"""places_identifier"""'}, {}), "('places_identifier')", False, 'from south.db import db\n'), ((118, 8, 118, 40), 'south.db.db.delete_table', 'db.delete_table', ({(118, 24, 118, 39): '"""places_entity"""'}, {}), "('places_entity')", False, 'from south.db import db\n'), ((121, 8, 121, 50), 'south.db.db.delete_table', 'db.delete_table', ({(121, 24, 121, 49): '"""places_entity_all_types"""'}, {}), "('places_entity_all_types')", False, 'from south.db import db\n'), ((124, 8, 124, 61), 'south.db.db.delete_table', 'db.delete_table', ({(124, 24, 124, 60): '"""places_entity_all_types_completion"""'}, {}), "('places_entity_all_types_completion')", False, 'from south.db import db\n'), ((127, 8, 127, 53), 'south.db.db.delete_table', 'db.delete_table', ({(127, 24, 127, 52): '"""places_entity__identifiers"""'}, {}), "('places_entity__identifiers')", False, 'from south.db import db\n'), ((35, 19, 35, 91), 'django.db.models.AutoField', 'models.AutoField', (), '', False, 'from django.db import models\n'), ((36, 32, 36, 87), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((37, 30, 37, 85), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((43, 19, 43, 91), 'django.db.models.AutoField', 'models.AutoField', (), '', False, 'from django.db import models\n'), ((44, 32, 44, 87), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((45, 30, 45, 85), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((77, 19, 77, 91), 'django.db.models.AutoField', 'models.AutoField', (), '', False, 'from django.db import models\n'), ((78, 23, 78, 74), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((79, 27, 79, 82), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((85, 19, 85, 91), 'django.db.models.AutoField', 'models.AutoField', (), '', False, 'from django.db import models\n'), ((86, 23, 86, 74), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((87, 27, 87, 82), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((93, 19, 93, 91), 'django.db.models.AutoField', 'models.AutoField', (), '', False, 'from django.db import models\n'), ((94, 23, 94, 74), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n'), ((95, 27, 95, 82), 'django.db.models.ForeignKey', 'models.ForeignKey', (), '', False, 'from django.db import models\n')]