django-orchestra-test/orchestra/contrib/databases/migrations/0001_initial.py

52 lines
2.2 KiB
Python
Raw Normal View History

2015-04-08 14:41:09 +00:00
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
2015-04-29 13:55:22 +00:00
import orchestra.core.validators
2015-04-08 14:41:09 +00:00
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Database',
fields=[
2015-04-29 13:55:22 +00:00
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
('name', models.CharField(validators=[orchestra.core.validators.validate_name], verbose_name='name', max_length=64)),
('type', models.CharField(max_length=32, verbose_name='type', choices=[('mysql', 'MySQL')], default='mysql')),
('account', models.ForeignKey(to=settings.AUTH_USER_MODEL, verbose_name='Account', related_name='databases')),
2015-04-08 14:41:09 +00:00
],
),
migrations.CreateModel(
name='DatabaseUser',
fields=[
2015-04-29 13:55:22 +00:00
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
('username', models.CharField(validators=[orchestra.core.validators.validate_name], verbose_name='username', max_length=16)),
('password', models.CharField(verbose_name='password', max_length=256)),
('type', models.CharField(max_length=32, verbose_name='type', choices=[('mysql', 'MySQL')], default='mysql')),
('account', models.ForeignKey(to=settings.AUTH_USER_MODEL, verbose_name='Account', related_name='databaseusers')),
2015-04-08 14:41:09 +00:00
],
options={
'verbose_name_plural': 'DB users',
},
),
migrations.AddField(
model_name='database',
name='users',
2015-04-29 13:55:22 +00:00
field=models.ManyToManyField(to='databases.DatabaseUser', verbose_name='users', blank=True, related_name='databases'),
2015-04-08 14:41:09 +00:00
),
migrations.AlterUniqueTogether(
name='databaseuser',
unique_together=set([('username', 'type')]),
),
migrations.AlterUniqueTogether(
name='database',
unique_together=set([('name', 'type')]),
),
]