How to use the django.db.migrations function in Django

To help you get started, we’ve selected a few Django examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LPgenerator / django-mmc / mmc / migrations / 0001_initial.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='MMCEmail',
            fields=[
                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
                ('created', models.DateField(auto_now=True)),
                ('email', models.EmailField(help_text=b'Email will be used for send all exceptions from command.', max_length=75)),
                ('is_active', models.BooleanField(default=True, help_text=b'Email may be switched off for a little while.')),
            ],
            options={
                'verbose_name': 'Email',
                'verbose_name_plural': 'Emails',
            },
            bases=(models.Model,),
        ),
        migrations.CreateModel(
            name='MMCHost',
            fields=[
github EuroPython / epcon / assopy / migrations / 0004_add_order_payment_date.py View on Github external
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('assopy', '0003_add_exrate_fields_to_invoice_model'),
    ]

    operations = [
        migrations.AddField(
            model_name='order',
            name='payment_date',
            field=models.DateTimeField(help_text=b'Auto filled by the payments backend', null=True, blank=True),
        ),
github theonion / django-bulbs / bulbs / notifications / migrations / 0001_initial.py View on Github external
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import djbetty.fields


class Migration(migrations.Migration):

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Notification',
            fields=[
                ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)),
                ('internal_title', models.CharField(max_length=512)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('headline', models.CharField(max_length=512)),
                ('is_published', models.BooleanField(default=False)),
                ('body', models.TextField(blank=True, null=True)),
                ('image', djbetty.fields.ImageField(blank=True, default=None, null=True)),
                ('clickthrough_url', models.URLField(blank=True, null=True)),
                ('clickthrough_cta', models.CharField(blank=True, max_length=30, null=True)),
            ],
            options={
                'abstract': False,
            },
github MFOSSociety / NSP / accounts / migrations / 0001_initial.py View on Github external
# Generated by Django 2.0.6 on 2018-07-23 15:32

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Follow',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('follower', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='follower', to=settings.AUTH_USER_MODEL)),
                ('following', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='following', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Skill',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('skill_name', models.CharField(blank=True, default='', max_length=100)),
github WeblateOrg / weblate / weblate / accounts / migrations / 0026_profile_special_chars.py View on Github external
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-02-11 15:30
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('accounts', '0025_auto_20170211_1609'),
    ]

    operations = [
        migrations.AddField(
            model_name='profile',
            name='special_chars',
            field=models.CharField(blank=True, default='', help_text='You can specify additional special characters to be shown in the visual keyboard while translating. It can be useful for chars you use frequently but are hard to type on your keyboard.', max_length=30, verbose_name='Special characters'),
        ),
github python / pythondotorg / jobs / migrations / 0003_auto_20150211_1738.py View on Github external
from django.db import models, migrations


def remove_job_submit_sidebar_box(apps, schema_editor):
    """
    Remove jobs-submitajob box
    """
    Box = apps.get_model('boxes', 'Box')
    try:
        submit_box = Box.objects.get(label='jobs-submitajob')
        submit_box.delete()
    except Box.DoesNotExist:
        pass


class Migration(migrations.Migration):

    dependencies = [
        ('jobs', '0002_auto_20150211_1634'),
        ('boxes', '0001_initial'),
    ]

    operations = [
        migrations.RunPython(remove_job_submit_sidebar_box),
    ]
github ngageoint / scale / scale / queue / migrations / 0015_auto_20170731_1527.py View on Github external
cpus = max(self.cpus_required, 0.25)
    resources.add(NodeResources([Cpus(cpus)]))
    return resources

def get_secrets_key(self):
    """Returns the reference key for job type secrets stored in the secrets backend.

    :returns: The job_type name and version concatenated
    :rtype: str
    """

    return '-'.join([self.name, self.version]).replace('.', '_')



class Migration(migrations.Migration):

    dependencies = [
        ('job', '0029_auto_20170707_1034'),
        ('product', '0010_auto_20170727_1349'),
        ('storage', '0008_auto_20170609_1443'),
        ('queue', '0014_queue'),
    ]

    def populate_queue(apps, schema_editor):
        from job.configuration.json.execution.exe_config import ExecutionConfiguration

        # Go through all of the queued job models and re-populate the queue table
        when_queued = now()
        Job = apps.get_model('job', 'Job')
        JobType = apps.get_model('job', 'JobType')
        JobExecution = apps.get_model('job', 'JobExecution')
github CenterForOpenScience / osf.io / osf / migrations / 0047_auto_20170803_1514.py View on Github external
# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2017-08-03 20:14
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('osf', '0046_merge_20170803_1147'),
    ]

    operations = [
        migrations.AddField(
            model_name='maintenancestate',
            name='level',
            field=models.IntegerField(choices=[(1, b'info'), (2, b'warning'), (3, b'danger')], default=1),
        ),
        migrations.AddField(
            model_name='maintenancestate',
            name='message',
            field=models.TextField(blank=True),
        ),
github uno-isqa-8950 / uno-cpi / partners / migrations / 0002_auto_20181105_2252.py View on Github external
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('university', '0001_initial'),
        ('partners', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='campuspartner',
            name='college_name',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='university.College'),
        ),
        migrations.AddField(
            model_name='campuspartner',
            name='department',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='university.Department'),
        ),
        migrations.AddField(
            model_name='campuspartner',
            name='education_system',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='university.EducationSystem'),
        ),
        migrations.AddField(
            model_name='campuspartner',