0001_initial.py 14.2 KB
Newer Older
BAIRE Anthony's avatar
BAIRE Anthony committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-12-19 15:14
from __future__ import unicode_literals

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import main.models
import main.validators
import taggit.managers


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('taggit', '0002_auto_20150616_2121'),
    ]

    operations = [
        migrations.CreateModel(
            name='AllgoUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('sshkey', models.TextField(blank=True, null=True, validators=[main.validators.sshkey_validator])),
                ('token', models.CharField(default=main.models.generate_token, max_length=32, validators=[main.validators.token_validator])),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='allgouser', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'dj_users',
                'verbose_name': 'allgo user',
                'verbose_name_plural': 'allgo users',
            },
        ),
        migrations.CreateModel(
            name='DockerOs',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('version', models.CharField(max_length=255, validators=[django.core.validators.RegexValidator('\\A[\\w][\\w.-]{0,127}\\Z', flags=256, message='Invalid docker tag')])),
                ('docker_name', models.CharField(max_length=255, validators=[django.core.validators.RegexValidator('\\A[a-zA-Z0-9][a-zA-Z0-9_.-]+\\Z', 'Invalid docker name')])),
            ],
            options={
                'db_table': 'dj_docker_os',
            },
        ),
        migrations.CreateModel(
            name='Job',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now_add=True)),
                ('param', models.CharField(blank=True, max_length=255, null=True, validators=[main.validators.job_param_validator])),
                ('datasize', models.IntegerField(blank=True, null=True)),
                ('version', models.CharField(max_length=255)),
                ('exec_time', models.IntegerField(blank=True, null=True)),
                ('access_token', models.CharField(blank=True, max_length=255, null=True, validators=[main.validators.token_validator])),
                ('state', models.IntegerField(choices=[(0, 'NEW'), (1, 'WAITING'), (2, 'RUNNING'), (4, 'ARCHIVED'), (3, 'DONE'), (5, 'DELETED'), (6, 'ABORTING')], default=0)),
                ('result', models.IntegerField(choices=[(0, 'NONE'), (1, 'SUCCESS'), (2, 'ERROR'), (3, 'ABORTED'), (4, 'TIMEOUT')], default=0)),
                ('container_id', models.CharField(blank=True, max_length=64, null=True, validators=[django.core.validators.RegexValidator('\\A[0-9a-f]{64}\\Z', 'Not a docker container id')])),
            ],
            options={
                'db_table': 'dj_jobs',
            },
        ),
        migrations.CreateModel(
            name='JobQueue',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now_add=True)),
                ('name', models.CharField(max_length=255)),
                ('timeout', models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)])),
                ('is_default', models.BooleanField()),
            ],
            options={
                'db_table': 'dj_job_queues',
            },
        ),
        migrations.CreateModel(
            name='Quota',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now_add=True)),
                ('quantity', models.BigIntegerField(blank=True, default=1000, null=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quotauser', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'dj_quotas',
            },
        ),
        migrations.CreateModel(
            name='Runner',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now_add=True)),
                ('token', models.CharField(default=main.models.generate_token, max_length=255, unique=True, validators=[main.validators.token_validator])),
                ('hostname', models.CharField(blank=True, max_length=255, null=True)),
                ('cpu_count', models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)])),
                ('mem_in_GB', models.IntegerField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(1)])),
                ('last_seen', models.DateTimeField(null=True)),
                ('open_bar', models.BooleanField(default=False)),
                ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='runneruser', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'dj_runners',
            },
        ),
        migrations.CreateModel(
            name='Tos',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('url', models.URLField(blank=True)),
                ('version', models.CharField(max_length=32, unique=True)),
            ],
            options={
                'db_table': 'dj_tos',
            },
        ),
        migrations.CreateModel(
            name='UserAgreement',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('tos', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='tos', to='main.Tos')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_agreement', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'dj_user_agreement',
            },
        ),
        migrations.CreateModel(
            name='Webapp',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now_add=True)),
                ('name', models.CharField(max_length=255, unique=True)),
                ('description', models.TextField(blank=True, null=True)),
                ('contact', models.CharField(blank=True, max_length=255, null=True)),
                ('logo_file_name', models.CharField(blank=True, max_length=255, null=True)),
                ('logo_content_type', models.CharField(blank=True, max_length=255, null=True)),
                ('logo_file_size', models.IntegerField(blank=True, null=True)),
                ('logo_updated_at', models.DateTimeField(blank=True, null=True)),
                ('default_quota', models.IntegerField(blank=True, null=True)),
                ('docker_name', models.CharField(max_length=255, unique=True, validators=[django.core.validators.RegexValidator('\\A[a-zA-Z0-9][a-zA-Z0-9_.-]+\\Z', 'Invalid docker name'), django.core.validators.RegexValidator('\\A(root\\Z|sshd\\Z|_)', inverse_match=True, message='This is a reserved name')])),
                ('readme', models.IntegerField(blank=True, null=True)),
                ('entrypoint', models.CharField(blank=True, max_length=255, validators=[django.core.validators.RegexValidator('\\A/[/\\w+._-]*[\\w+._-]\\Z', 'Malformatted path')])),
                ('exec_time', models.IntegerField(blank=True, null=True)),
                ('private', models.BooleanField(default=1)),
                ('access_token', models.CharField(blank=True, max_length=255, null=True, validators=[main.validators.token_validator])),
                ('sandbox_state', models.IntegerField(choices=[(0, 'IDLE'), (1, 'RUNNING'), (2, 'STARTING'), (3, 'START_ERROR'), (4, 'STOPPING'), (5, 'STOP_ERROR')], default=0, null=True)),
                ('notebook_gitrepo', models.CharField(blank=True, max_length=255, null=True)),
                ('memory_limit', models.BigIntegerField(null=True, validators=[django.core.validators.MinValueValidator(0)])),
                ('imported', models.BooleanField(default=False)),
                ('docker_os', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='webappdockeros', to='main.DockerOs')),
                ('job_queue', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='webappjobqueue', to='main.JobQueue')),
            ],
            options={
                'db_table': 'dj_webapps',
            },
        ),
168
        # webapp ids below 1000 are reserved for webapps imported from the old allgo instance
BAIRE Anthony's avatar
BAIRE Anthony committed
169
170
        # FIXME: this is broken, the change is not applied (maybe we should have put it in a separate migration)
        #migrations.RunSQL("ALTER TABLE dj_webapps AUTO_INCREMENT=1000;"),
BAIRE Anthony's avatar
BAIRE Anthony committed
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
        migrations.CreateModel(
            name='WebappParameter',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now_add=True)),
                ('value', models.CharField(max_length=255, validators=[main.validators.job_param_validator])),
                ('name', models.CharField(max_length=255)),
                ('detail', models.CharField(blank=True, max_length=255, null=True)),
                ('webapp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='webappparameters', to='main.Webapp')),
            ],
            options={
                'db_table': 'dj_webapp_parameters',
            },
        ),
        migrations.CreateModel(
            name='WebappVersion',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now_add=True)),
                ('number', models.CharField(max_length=255, validators=[django.core.validators.RegexValidator('\\A[\\w][\\w.-]{0,127}\\Z', flags=256, message='Invalid docker tag'), django.core.validators.RegexValidator('\\Asandbox\\Z', inverse_match=True, message='This is a reserved name')])),
                ('description', models.CharField(blank=True, max_length=255)),
                ('docker_image_size', models.FloatField(blank=True, null=True)),
                ('state', models.IntegerField(choices=[(0, 'SANDBOX'), (1, 'COMMITTED'), (2, 'READY'), (3, 'ERROR'), (4, 'REPLACED'), (5, 'USER'), (6, 'IMPORT')])),
                ('published', models.BooleanField()),
                ('imported', models.BooleanField(default=False)),
                ('webapp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='webapp', to='main.Webapp')),
            ],
            options={
                'db_table': 'dj_webapp_versions',
            },
        ),
        migrations.AddField(
            model_name='webapp',
            name='sandbox_version',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='webappversions', to='main.WebappVersion'),
        ),
        migrations.AddField(
            model_name='webapp',
            name='tags',
            field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'),
        ),
        migrations.AddField(
            model_name='webapp',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='webappuser', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='runner',
            name='webapps',
            field=models.ManyToManyField(related_name='webapps', to='main.Webapp'),
        ),
        migrations.AddField(
            model_name='quota',
            name='webapp',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='quotawebapp', to='main.Webapp'),
        ),
        migrations.AddField(
            model_name='job',
            name='queue',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='job_queue', to='main.JobQueue'),
        ),
        migrations.AddField(
            model_name='job',
            name='runner',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='runner', to='main.Runner'),
        ),
        migrations.AddField(
            model_name='job',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='job',
            name='webapp',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='job_webapp', to='main.Webapp'),
        ),
    ]