from __future__ import unicode_literals

from django.db import migrations, models
import ideascube.search.models


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Search',
            fields=[
                ('rowid', models.IntegerField(serialize=False, primary_key=True)),
                ('model', models.CharField(max_length=64)),
                ('model_id', models.IntegerField()),
                ('public', models.BooleanField(default=True)),
                ('text', ideascube.search.models.SearchField()),
            ],
            options={
                'db_table': 'idx',
                'managed': False,
            },
        ),
    ]

from __future__ import unicode_literals

from django.db import migrations
from ideascube.search.utils import create_index_table


class CreateSearchModel(migrations.CreateModel):
    def database_forwards(self, *_):
        # Don't run the parent method, we create the table our own way
        create_index_table()


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        CreateSearchModel(
            name='Search',
            fields=[],
            options={
                'db_table': 'idx',
                'managed': False,
            },
        ),
    ]

Fix the initial search migration
Fix the initial search migration

There is no point in creating the model in this way, that's just not how
it's used: instead we want to use the FTS4 extension from SQLite.

  from __future__ import unicode_literals
  
- from django.db import migrations, models
+ from django.db import migrations
- import ideascube.search.models
+ from ideascube.search.utils import create_index_table
+ 
+ 
+ class CreateSearchModel(migrations.CreateModel):
+     def database_forwards(self, *_):
+         # Don't run the parent method, we create the table our own way
+         create_index_table()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
      ]
  
      operations = [
-         migrations.CreateModel(
+         CreateSearchModel(
              name='Search',
-             fields=[
+             fields=[],
-                 ('rowid', models.IntegerField(serialize=False, primary_key=True)),
-                 ('model', models.CharField(max_length=64)),
-                 ('model_id', models.IntegerField()),
-                 ('public', models.BooleanField(default=True)),
-                 ('text', ideascube.search.models.SearchField()),
-             ],
              options={
                  'db_table': 'idx',
                  'managed': False,
              },
          ),
      ]
  
Fix the initial search migration
## Code Before:
from __future__ import unicode_literals

from django.db import migrations, models
import ideascube.search.models


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Search',
            fields=[
                ('rowid', models.IntegerField(serialize=False, primary_key=True)),
                ('model', models.CharField(max_length=64)),
                ('model_id', models.IntegerField()),
                ('public', models.BooleanField(default=True)),
                ('text', ideascube.search.models.SearchField()),
            ],
            options={
                'db_table': 'idx',
                'managed': False,
            },
        ),
    ]

## Instruction:
Fix the initial search migration
## Code After:
from __future__ import unicode_literals

from django.db import migrations
from ideascube.search.utils import create_index_table


class CreateSearchModel(migrations.CreateModel):
    def database_forwards(self, *_):
        # Don't run the parent method, we create the table our own way
        create_index_table()


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        CreateSearchModel(
            name='Search',
            fields=[],
            options={
                'db_table': 'idx',
                'managed': False,
            },
        ),
    ]
