Skip to content

Commit

Permalink
feature #155: Setup infra
Browse files Browse the repository at this point in the history
  • Loading branch information
dschreij committed Apr 21, 2024
1 parent b3a2329 commit 4accc39
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/Models/StudyData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'

/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */
const Model = use('Model')

class StudyData extends Model {
participant () {
return this.belongsTo('App/Models/Participant')
}

study () {
return this.belongsTo('App/Models/Study')
}
}
module.exports = StudyData
25 changes: 25 additions & 0 deletions database/migrations/1713706945813_study_data_schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict'

/** @type {import('@adonisjs/lucid/src/Schema')} */
const Schema = use('Schema')

class StudyDataSchema extends Schema {
up () {
this.create('study_data', (table) => {
table.increments()
table.integer('study_id').unsigned().notNullable()
table.integer('participant_id').unsigned().notNullable()
table.specificType('data', 'json')
table.timestamps()

table.foreign('participant_id').references('id').inTable('participants').onDelete('cascade')
table.foreign('study_id').references('id').inTable('studies').onDelete('cascade')
})
}

down () {
this.drop('study_data')
}
}

module.exports = StudyDataSchema

0 comments on commit 4accc39

Please sign in to comment.