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

52 lines
2.3 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 14:32:38 +00:00
('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)),
('name', models.CharField(verbose_name='name', max_length=64, validators=[orchestra.core.validators.validate_name])),
('type', models.CharField(default='mysql', choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], verbose_name='type', max_length=32)),
('account', models.ForeignKey(related_name='databases', verbose_name='Account', to=settings.AUTH_USER_MODEL)),
2015-04-08 14:41:09 +00:00
],
),
migrations.CreateModel(
name='DatabaseUser',
fields=[
2015-04-29 14:32:38 +00:00
('id', models.AutoField(serialize=False, primary_key=True, verbose_name='ID', auto_created=True)),
('username', models.CharField(verbose_name='username', max_length=16, validators=[orchestra.core.validators.validate_name])),
2015-04-29 13:55:22 +00:00
('password', models.CharField(verbose_name='password', max_length=256)),
2015-04-29 14:32:38 +00:00
('type', models.CharField(default='mysql', choices=[('mysql', 'MySQL'), ('postgres', 'PostgreSQL')], verbose_name='type', max_length=32)),
('account', models.ForeignKey(related_name='databaseusers', verbose_name='Account', to=settings.AUTH_USER_MODEL)),
2015-04-08 14:41:09 +00:00
],
options={
'verbose_name_plural': 'DB users',
},
),
migrations.AddField(
model_name='database',
name='users',
2015-04-29 14:32:38 +00:00
field=models.ManyToManyField(related_name='databases', to='databases.DatabaseUser', verbose_name='users', blank=True),
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')]),
),
]