Commit 7fa7654c authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Switched schema to p1_11_5.

parent c07c6077
......@@ -20,3 +20,5 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False
SECRET_KEY = 'InVzZXIxQGdtlsLmNvbSI.YH6iB4wE5dDMNjpf-cX2Q9MIjyY'
# not used right now
# SAML_PATH = 'saml'
schema = 'p1_11_5'
......@@ -18,6 +18,7 @@ from . import db, ma
from sqlalchemy import func
from sqlalchemy.dialects.postgresql import JSON
# from .utils import sum_form
from app.config import schema
############################
# SQLAlchemy Model
......@@ -26,7 +27,7 @@ from sqlalchemy.dialects.postgresql import JSON
class Material(db.Model):
__tablename__ = 'material'
__table_args__ = {'schema': 'p34'}
__table_args__ = {'schema': schema}
id = db.Column(db.Integer, primary_key=True)
material_name = db.Column(db.Text, index=True)
......@@ -80,14 +81,14 @@ class Material(db.Model):
class Element(db.Model):
__tablename__ = 'element'
__table_args__ = {'schema': 'p34'}
__table_args__ = {'schema': schema}
id = db.Column(db.Integer, primary_key=True)
label = db.Column(db.Integer, index=True)
position = db.Column(db.String(256), nullable=False)
wyckoff = db.Column(db.Text, nullable=False)
material_id = db.Column(db.ForeignKey(
'p34.material.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
'%s.material.id' % schema, ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
def export_data(self):
return {
......@@ -101,7 +102,7 @@ class Element(db.Model):
class Cell(db.Model):
__tablename__ = 'cell'
__table_args__ = {'schema': 'p34'}
__table_args__ = {'schema': schema}
id = db.Column(db.Integer, primary_key=True)
is_primitive = db.Column(db.Boolean, nullable=False)
......@@ -109,7 +110,7 @@ class Cell(db.Model):
b = db.Column(db.String(256), nullable=False)
c = db.Column(db.String(256), nullable=False)
material_id = db.Column(db.ForeignKey(
'p34.material.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
'%s.material.id' % schema, ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
def export_data(self):
return {
......@@ -124,14 +125,14 @@ class Cell(db.Model):
class MaterialClassification(db.Model):
__tablename__ = 'material_classification'
__table_args__ = {'schema': 'p34'}
__table_args__ = {'schema': schema}
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Text, nullable=False)
class_type = db.Column(db.Enum('material_class_springer',
'compound_class_springer', name='material_class_t'), nullable=False)
material_id = db.Column(db.ForeignKey(
'p34.material.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
'%s.material.id' % schema, ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
def export_data(self):
return {
......@@ -144,7 +145,7 @@ class MaterialClassification(db.Model):
class Calc(db.Model):
__tablename__ = 'calc'
__table_args__ = {'schema': 'p34'}
__table_args__ = {'schema': schema}
id = db.Column(db.Integer, primary_key=True)
run_type = db.Column(db.Enum('single point',
......@@ -196,7 +197,7 @@ class Calc(db.Model):
src_filepath = db.Column(db.Text, nullable=False)
material_id = db.Column(db.ForeignKey(
'p34.material.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
'%s.material.id' % schema, ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
energy = db.relationship('EnergyDecomposition', backref='calc')
contributor = db.relationship('Contributor', backref='calc')
......@@ -250,12 +251,12 @@ class Calc(db.Model):
class EnergyDecomposition(db.Model):
__tablename__ = 'energy'
__table_args__ = {'schema': 'p34'}
__table_args__ = {'schema': schema}
id = db.Column(db.Integer, primary_key=True)
e_val = db.Column(db.Float(53), nullable=False)
e_kind = db.Column(db.Text)
calc_id = db.Column(db.ForeignKey('p34.calc.id',
calc_id = db.Column(db.ForeignKey('%s.calc.id' % schema,
ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
def export_data(self):
......@@ -269,14 +270,14 @@ class EnergyDecomposition(db.Model):
class Contributor(db.Model):
__tablename__ = 'contributor'
__table_args__ = {'schema': 'p34'}
__table_args__ = {'schema': schema}
id = db.Column(db.Integer, primary_key=True)
first_name = db.Column(db.Text, nullable=False, index=True)
last_name = db.Column(db.Text, nullable=False, index=True)
contributor_type = db.Column(db.Enum(
'uploader', 'coauthor', name='contributor_t'), nullable=False, index=True)
calc_id = db.Column(db.ForeignKey('p34.calc.id',
calc_id = db.Column(db.ForeignKey('%s.calc.id' % schema,
ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
def export_data(self):
......@@ -291,12 +292,12 @@ class Contributor(db.Model):
class CalculationReference(db.Model):
__tablename__ = 'calculation_reference'
__table_args__ = {'schema': 'p34'}
__table_args__ = {'schema': schema}
id = db.Column(db.Integer, primary_key=True)
ref_target = db.Column(db.Text, nullable=False)
ref_type = db.Column(db.Text, nullable=False)
calc_id = db.Column(db.ForeignKey('p34.calc.id',
calc_id = db.Column(db.ForeignKey('%s.calc.id' % schema,
ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
def export_data(self):
......@@ -310,7 +311,7 @@ class CalculationReference(db.Model):
class DiagramData(db.Model):
__tablename__ = 'diagram_data'
__table_args__ = {'schema': 'p34'}
__table_args__ = {'schema': schema}
id = db.Column(db.Integer, primary_key=True)
data_content = db.Column(db.Text, nullable=False)
......@@ -323,7 +324,7 @@ class DiagramData(db.Model):
'qha_specific_heat_cv',
'qha_thermal_expansion',
'gw_spectral_function', name='diagram_data_t'), nullable=False, index=True)
calc_id = db.Column(db.ForeignKey('p34.calc.id',
calc_id = db.Column(db.ForeignKey('%s.calc.id' % schema,
ondelete='CASCADE', onupdate='CASCADE'), nullable=False)
def export_data(self):
......
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