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 django.db import models
class ArInternalMetadata(models.Model):
key = models.CharField(primary_key=True, max_length=255)
value = models.CharField(max_length=255, blank=True, null=True)
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
class TimeStampModel(models.Model):
"""
An abstract base class model that provides self-updating ``created_at`` and
``updated_at`` fields.
"""
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now_add=True)
class Meta:
db_table = 'ar_internal_metadata'
abstract = True
class Users(models.Model):
email = models.CharField(unique=True, max_length=255)
encrypted_password = models.CharField(max_length=255)
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)
class DockerOs(models.Model):
"""
Docstring to update
"""
# 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:
db_table = 'users'
db_table = 'docker_os'
class Webapps(models.Model):
name = models.CharField(unique=True, max_length=255, blank=True, null=True)
class Webapp(TimeStampModel):
"""
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)
# Should given according to the number of users declared as admin to this
# app
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_content_type = models.CharField(max_length=255, blank=True, null=True)
logo_file_size = models.IntegerField(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)
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)
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)
private = models.IntegerField(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)
default_job_queue_id = models.IntegerField()
memory_limit = models.BigIntegerField(blank=True, null=True)
default_job_queue_id = models.IntegerField(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:
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)
version = models.CharField(max_length=255, blank=True, null=True)
docker_name = models.CharField(max_length=255, blank=True, null=True)
detail = models.CharField(max_length=255, blank=True, null=True)
# Relationships
# a Webapp parameters corresponds to one webapp
webapp = models.ForeignKey(Webapp)
class Meta:
db_table = 'docker_os'
db_table = 'webapp_parameters'
class JobQueues(models.Model):
name = models.CharField(max_length=255)
timeout = models.IntegerField(blank=True, null=True)
is_default = models.IntegerField()
created_at = models.DateTimeField()
updated_at = models.DateTimeField()
class WebappVersion(TimeStampModel):
"""
Docstring to update
"""
# 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:
db_table = 'job_queues'
db_table = 'webapp_versions'
class JobUploads(models.Model):
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)
job_file_file_size = models.IntegerField(blank=True, null=True)
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 User(TimeStampModel):
"""
User model regrouping information related to its email, password hash,
token, SSH key, ...
"""
class Meta:
db_table = 'job_uploads'
# Fields
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):
webapp_id = models.IntegerField(blank=True, null=True)
user_id = models.IntegerField(blank=True, null=True)
created_at = models.DateTimeField(blank=True, null=True)
updated_at = models.DateTimeField(blank=True, null=True)
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()
container_id = models.CharField(max_length=64, blank=True, null=True)
queue_id = models.IntegerField()
result = models.IntegerField()
# Signin/out
"""
These fields should be updated through the database and a method.
I don't see the difference between the last_sign_in_at and
current_sign_in_at fields. For me, they the same purpose
"""
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)
class Meta:
db_table = 'jobs'
# IP data
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):
#user_id = models.IntegerField()
webapp_id = models.IntegerField()
quantity = models.BigIntegerField(blank=True, null=True)
created_at = models.DateTimeField(blank=True, null=True)
updated_at = models.DateTimeField(blank=True, null=True)
# Token information
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)
# 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:
db_table = 'quotas'
db_table = 'users'
class SchemaMigrations(models.Model):
version = models.CharField(unique=True, max_length=255)
class Quota(TimeStampModel):
"""
Docstring to update
"""
class Meta:
db_table = 'schema_migrations'
user = models.ForeignKey(User, on_delete=models.CASCADE)
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:
db_table = 'taggings'
unique_together = (('tag_id', 'taggable_id', 'taggable_type', 'context', 'tagger_id', 'tagger_type'),)
db_table = 'quotas'
class Tags(models.Model):
name = models.CharField(unique=True, max_length=255, blank=True, null=True)
taggings_count = models.IntegerField(blank=True, null=True)
class JobQueue(TimeStampModel):
"""
Docstring to edit
"""
# Fields
name = models.CharField(max_length=255)
timeout = models.IntegerField(blank=True, null=True)
is_default = models.IntegerField()
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:
db_table = 'webapp_demos'
db_table = 'jobs'
class WebappParameters(models.Model):
value = models.CharField(max_length=255, blank=True, null=True)
name = models.CharField(max_length=255, blank=True, null=True)
detail = models.CharField(max_length=255, blank=True, null=True)
webapp_id = models.IntegerField(blank=True, null=True)
class Meta:
db_table = 'webapp_parameters'
class JobUploads(models.Model):
"""
Docstring to edit
"""
# 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):
number = models.CharField(max_length=255, blank=True, null=True)
changelog = 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)
webapp_id = models.IntegerField(blank=True, null=True)
docker_image_size = models.FloatField(blank=True, null=True)
state = models.IntegerField()
published = models.IntegerField()
# Relationships
# A job upload corresponds to one job
job = models.ForeignKey(Job)
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