Commit c1e96ee1 authored by BERJON Matthieu's avatar BERJON Matthieu

Complete update of the model

I updated the model in order to satisfy the rails model and have a
smooth import system.

I created an abstract model for the timestamps at creation and update on
each table.

I added the minimal tables necessary for the v1.0 and ordered them to
take into account of the different constraints.
Signed-off-by: BERJON Matthieu's avatarMatthieu Berjon <matthieu.berjon@inria.fr>
parent 14160032
# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey has `on_delete` set to the desired behavior.
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from __future__ import unicode_literals from __future__ import unicode_literals
from django.db import models from django.db import models
class ArInternalMetadata(models.Model): class TimeStampModel(models.Model):
key = models.CharField(primary_key=True, max_length=255) """
value = models.CharField(max_length=255, blank=True, null=True) An abstract base class model that provides self-updating ``created_at`` and
created_at = models.DateTimeField() ``updated_at`` fields.
updated_at = models.DateTimeField() """
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now_add=True)
class Meta: class Meta:
db_table = 'ar_internal_metadata' abstract = True
class Users(models.Model): class DockerOs(models.Model):
email = models.CharField(unique=True, max_length=255) """
encrypted_password = models.CharField(max_length=255) Docstring to update
reset_password_token = models.CharField(unique=True, max_length=255, blank=True, null=True) """
reset_password_sent_at = models.DateTimeField(blank=True, null=True)
remember_created_at = models.DateTimeField(blank=True, null=True)
sign_in_count = models.IntegerField()
current_sign_in_at = models.DateTimeField(blank=True, null=True)
last_sign_in_at = models.DateTimeField(blank=True, null=True)
current_sign_in_ip = models.CharField(max_length=255, blank=True, null=True)
last_sign_in_ip = models.CharField(max_length=255, blank=True, null=True)
created_at = models.DateTimeField(blank=True, null=True)
updated_at = models.DateTimeField(blank=True, null=True)
admin = models.IntegerField(blank=True, null=True)
confirmation_token = models.CharField(unique=True, max_length=255, blank=True, null=True)
confirmed_at = models.DateTimeField(blank=True, null=True)
confirmation_sent_at = models.DateTimeField(blank=True, null=True)
sshkey = models.TextField(blank=True, null=True)
auth_token = models.CharField(max_length=255, blank=True, null=True)
# Fields
name = models.CharField(max_length=255, blank=True)
version = models.CharField(max_length=255, blank=True)
docker_name = models.CharField(max_length=255, blank=True)
class Meta: class Meta:
db_table = 'users' db_table = 'docker_os'
class Webapps(models.Model): class Webapp(TimeStampModel):
name = models.CharField(unique=True, max_length=255, blank=True, null=True) """
Webapp model related to the creation and management of a particular web
app belonging to one or more users.
"""
# Fields
name = models.CharField(unique=True, max_length=255, blank=True)
description = models.TextField(blank=True, null=True) description = models.TextField(blank=True, null=True)
# Should given according to the number of users declared as admin to this
# app
contact = models.CharField(max_length=255, blank=True, null=True) contact = models.CharField(max_length=255, blank=True, null=True)
created_at = models.DateTimeField(blank=True, null=True)
updated_at = models.DateTimeField(blank=True, null=True) # Logo
logo_file_name = models.CharField(max_length=255, blank=True, null=True) logo_file_name = models.CharField(max_length=255, blank=True, null=True)
logo_content_type = models.CharField(max_length=255, blank=True, null=True) logo_content_type = models.CharField(max_length=255, blank=True, null=True)
logo_file_size = models.IntegerField(blank=True, null=True) logo_file_size = models.IntegerField(blank=True, null=True)
logo_updated_at = models.DateTimeField(blank=True, null=True) logo_updated_at = models.DateTimeField(blank=True, null=True)
user_id = models.IntegerField(blank=True, null=True)
# Not used yet
user_other = models.IntegerField(blank=True, null=True)
# Default quota
default_quota = models.IntegerField(blank=True, null=True) default_quota = models.IntegerField(blank=True, null=True)
docker_os_id = models.IntegerField(blank=True, null=True)
docker_name = models.CharField(max_length=255, blank=True, null=True) # A webapp has one docker os type
docker_os = models.ForeignKey(DockerOs)
# Docker and parameters related stuff
docker_name = models.CharField(max_length=255, blank=True)
readme = models.IntegerField(blank=True, null=True) readme = models.IntegerField(blank=True, null=True)
entrypoint = models.CharField(max_length=255, blank=True, null=True) entrypoint = models.CharField(max_length=255, blank=True)
exec_time = models.IntegerField(blank=True, null=True) exec_time = models.IntegerField(blank=True, null=True)
private = models.IntegerField(blank=True, null=True) private = models.IntegerField(blank=True, null=True)
access_token = models.CharField(max_length=255, blank=True, null=True) access_token = models.CharField(max_length=255, blank=True, null=True)
sandbox_state = models.IntegerField() sandbox_state = models.IntegerField(null=True)
# Not integrated in this model yet
sandbox_version_id = models.IntegerField(blank=True, null=True) sandbox_version_id = models.IntegerField(blank=True, null=True)
default_job_queue_id = models.IntegerField() default_job_queue_id = models.IntegerField(null=True)
memory_limit = models.BigIntegerField(blank=True, null=True)
class Meta:
db_table = 'webapps'
memory_limit = models.BigIntegerField(blank=True, null=True)
class Datasets(models.Model):
name = models.CharField(max_length=255)
size = models.IntegerField(blank=True, null=True)
extension = models.CharField(max_length=255, blank=True, null=True)
user_id = models.IntegerField(blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
file_name = models.CharField(max_length=255, blank=True, null=True)
class Meta: class Meta:
db_table = 'datasets' db_table = 'webapps'
class WebappParameter(models.Model):
"""
Docstring to update
"""
class DockerOs(models.Model): # Fields
value = models.CharField(max_length=255, blank=True, null=True)
name = models.CharField(max_length=255, blank=True, null=True) name = models.CharField(max_length=255, blank=True, null=True)
version = models.CharField(max_length=255, blank=True, null=True) detail = models.CharField(max_length=255, blank=True, null=True)
docker_name = models.CharField(max_length=255, blank=True, null=True)
# Relationships
# a Webapp parameters corresponds to one webapp
webapp = models.ForeignKey(Webapp)
class Meta: class Meta:
db_table = 'docker_os' db_table = 'webapp_parameters'
class JobQueues(models.Model): class WebappVersion(TimeStampModel):
name = models.CharField(max_length=255) """
timeout = models.IntegerField(blank=True, null=True) Docstring to update
is_default = models.IntegerField() """
created_at = models.DateTimeField()
updated_at = models.DateTimeField() # Fields
number = models.CharField(max_length=255, blank=True)
changelog = models.CharField(max_length=255, blank=True)
webapp = models.ForeignKey(Webapp)
docker_image_size = models.FloatField(blank=True, null=True)
state = models.IntegerField(null=True)
published = models.IntegerField()
class Meta: class Meta:
db_table = 'job_queues' db_table = 'webapp_versions'
class JobUploads(models.Model): class User(TimeStampModel):
job_file_file_name = models.CharField(max_length=255, blank=True, null=True) """
job_file_content_type = models.CharField(max_length=255, blank=True, null=True) User model regrouping information related to its email, password hash,
job_file_file_size = models.IntegerField(blank=True, null=True) token, SSH key, ...
job_file_updated_at = models.DateTimeField(blank=True, null=True) """
type = models.CharField(max_length=255, blank=True, null=True)
job_id = models.IntegerField(blank=True, null=True)
class Meta: # Fields
db_table = 'job_uploads' email = models.CharField(unique=True, max_length=255)
## Password management
encrypted_password = models.CharField(max_length=255)
reset_password_token = models.CharField(unique=True, null=True, max_length=255)
reset_password_sent_at = models.DateTimeField(blank=True, null=True)
remember_created_at = models.DateTimeField(blank=True, null=True)
class Jobs(models.Model): # Signin/out
webapp_id = models.IntegerField(blank=True, null=True) """
user_id = models.IntegerField(blank=True, null=True) These fields should be updated through the database and a method.
created_at = models.DateTimeField(blank=True, null=True) I don't see the difference between the last_sign_in_at and
updated_at = models.DateTimeField(blank=True, null=True) current_sign_in_at fields. For me, they the same purpose
param = models.CharField(max_length=255, blank=True, null=True) """
datasize = models.IntegerField(blank=True, null=True) sign_in_count = models.IntegerField()
version = models.CharField(max_length=255, blank=True, null=True) current_sign_in_at = models.DateTimeField(blank=True, null=True)
exec_time = models.IntegerField(blank=True, null=True) last_sign_in_at = models.DateTimeField(blank=True, null=True)
size_generated_data = models.IntegerField(blank=True, null=True)
ipaddress = models.CharField(max_length=255, blank=True, null=True)
access_token = models.CharField(max_length=255, blank=True, null=True)
state = models.IntegerField()
container_id = models.CharField(max_length=64, blank=True, null=True)
queue_id = models.IntegerField()
result = models.IntegerField()
class Meta: # IP data
db_table = 'jobs' current_sign_in_ip = models.CharField(max_length=255, blank=True, null=True)
last_sign_in_ip = models.CharField(max_length=255, blank=True, null=True)
# Is admin
admin = models.IntegerField(default=False)
class Quotas(models.Model): # Token information
#user_id = models.IntegerField() confirmation_token = models.CharField(unique=True, max_length=255, blank=True, null=True)
webapp_id = models.IntegerField() confirmed_at = models.DateTimeField(blank=True, null=True)
quantity = models.BigIntegerField(blank=True, null=True) confirmation_sent_at = models.DateTimeField(blank=True, null=True)
created_at = models.DateTimeField(blank=True, null=True)
updated_at = models.DateTimeField(blank=True, null=True) sshkey = models.TextField(blank=True, null=True)
auth_token = models.CharField(max_length=255, blank=True, null=True)
# Relationships # Relationships
user = models.ForeignKey(Users, on_delete=models.CASCADE, null=True) """
# webapp_id = models.ForeignKey(Webapps, on_delete=models.CASCADE, null=True) - A user can possess several webapps
- A webapp can possess several users (not only one admin)
"""
webapp = models.ManyToManyField(Webapp, through='Quota')
class Meta: class Meta:
db_table = 'quotas' db_table = 'users'
class SchemaMigrations(models.Model): class Quota(TimeStampModel):
version = models.CharField(unique=True, max_length=255) """
Docstring to update
"""
class Meta: user = models.ForeignKey(User, on_delete=models.CASCADE)
db_table = 'schema_migrations' webapp = models.ForeignKey(Webapp, on_delete=models.CASCADE)
# Fields
quantity = models.BigIntegerField(blank=True, null=True)
class Taggings(models.Model):
tag_id = models.IntegerField(blank=True, null=True)
taggable_id = models.IntegerField(blank=True, null=True)
taggable_type = models.CharField(max_length=255, blank=True, null=True)
tagger_id = models.IntegerField(blank=True, null=True)
tagger_type = models.CharField(max_length=255, blank=True, null=True)
context = models.CharField(max_length=128, blank=True, null=True)
created_at = models.DateTimeField(blank=True, null=True)
class Meta: class Meta:
db_table = 'taggings' db_table = 'quotas'
unique_together = (('tag_id', 'taggable_id', 'taggable_type', 'context', 'tagger_id', 'tagger_type'),)
class Tags(models.Model): class JobQueue(TimeStampModel):
name = models.CharField(unique=True, max_length=255, blank=True, null=True) """
taggings_count = models.IntegerField(blank=True, null=True) Docstring to edit
"""
# Fields
name = models.CharField(max_length=255)
timeout = models.IntegerField(blank=True, null=True)
is_default = models.IntegerField()
class Meta: class Meta:
db_table = 'tags' db_table = 'job_queues'
class Job(TimeStampModel):
"""
Docstring to update
"""
webapp = models.ForeignKey(Webapp)
user = models.ForeignKey(User)
# Fields
param = models.CharField(max_length=255, blank=True, null=True)
datasize = models.IntegerField(blank=True, null=True)
version = models.CharField(max_length=255, blank=True, null=True)
exec_time = models.IntegerField(blank=True, null=True)
size_generated_data = models.IntegerField(blank=True, null=True)
ipaddress = models.CharField(max_length=255, blank=True, null=True)
access_token = models.CharField(max_length=255, blank=True, null=True)
state = models.IntegerField()
# Not in use
container_id = models.IntegerField(blank=True, null=True)
queue = models.ForeignKey(JobQueue)
result = models.IntegerField()
class WebappDemos(models.Model):
name = models.CharField(max_length=255, blank=True, null=True)
extension = models.CharField(max_length=255, blank=True, null=True)
webapp_id = models.IntegerField(blank=True, null=True)
file_type = models.CharField(max_length=255, blank=True, null=True)
class Meta: class Meta:
db_table = 'webapp_demos' db_table = 'jobs'
class WebappParameters(models.Model): class JobUploads(models.Model):
value = models.CharField(max_length=255, blank=True, null=True) """
name = models.CharField(max_length=255, blank=True, null=True) Docstring to edit
detail = models.CharField(max_length=255, blank=True, null=True) """
webapp_id = models.IntegerField(blank=True, null=True)
class Meta:
db_table = 'webapp_parameters'
# Fields
job_file_file_name = models.CharField(max_length=255, blank=True)
job_file_content_type = models.CharField(max_length=255, blank=True)
job_file_file_size = models.IntegerField(blank=True, null=True)
job_file_updated_at = models.DateTimeField(blank=True, auto_now_add=True, null=True)
type = models.CharField(max_length=255, null=True)
class WebappVersions(models.Model): # Relationships
number = models.CharField(max_length=255, blank=True, null=True) # A job upload corresponds to one job
changelog = models.CharField(max_length=255, blank=True, null=True) job = models.ForeignKey(Job)
created_at = models.DateTimeField(blank=True, null=True)
updated_at = models.DateTimeField(blank=True, null=True)
webapp_id = models.IntegerField(blank=True, null=True)
docker_image_size = models.FloatField(blank=True, null=True)
state = models.IntegerField()
published = models.IntegerField()
class Meta: class Meta:
db_table = 'webapp_versions' db_table = 'job_uploads'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment