Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ typings/
.env

src/routes/playground.js
internal
internal
.vscode
10 changes: 10 additions & 0 deletions migrations/20180327134315_create_surveys_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exports.up = (knex, Promise) =>
knex.schema.createTable('surveys', (table) => {
table.increments('id')
table.string('title')
table.string('prize')
table.string('link')
table.string('promo')
})

exports.down = (knex, Promise) => knex.schema.dropTable('surveys')
14 changes: 14 additions & 0 deletions migrations/20180327134715_create_surveyquestions_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
exports.up = (knex, Promise) =>
knex.schema.createTable('surveyquestions', (table) => {
table.increments('id')
table.string('prompt')
table.string('type')
table.integer('survey_id')
.unsigned().index()
.references('id').inTable('surveys')
.onDelete('CASCADE')
.onUpdate('CASCADE')
table.integer('order').unsigned()
})

exports.down = (knex, Promise) => knex.schema.dropTable('surveyquestions')
13 changes: 13 additions & 0 deletions migrations/20180327135516_create_surveychoices_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
exports.up = (knex, Promise) =>
knex.schema.createTable('surveychoices', (table) => {
table.increments('id')
table.integer('surveyquestion_id')
.unsigned().index()
.references('id').inTable('surveyquestions')
.onDelete('CASCADE')
.onUpdate('CASCADE')
table.string('value')
table.integer('order').unsigned()
})

exports.down = (knex, Promise) => knex.schema.dropTable('surveychoices')
21 changes: 21 additions & 0 deletions migrations/20180327141652_create_surveysubmissions_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
exports.up = (knex, Promise) =>
knex.schema.createTable('surveysubmissions', (table) => {
table.increments('id')
table.integer('hackathon_id')
.unsigned().index()
.references('id').inTable('hackathons')
.onDelete('CASCADE')
.onUpdate('CASCADE')
table.integer('survey_id')
.unsigned().index()
.references('id').inTable('surveys')
.onDelete('CASCADE')
.onUpdate('CASCADE')
table.integer('student_id')
.unsigned().index()
.references('id').inTable('students')
.onDelete('CASCADE')
.onUpdate('CASCADE')
})

exports.down = (knex, Promise) => knex.schema.dropTable('surveysubmissions')
22 changes: 22 additions & 0 deletions migrations/20180327141653_create_surveyanswers_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
exports.up = (knex, Promise) =>
knex.schema.createTable('surveyanswers', (table) => {
table.increments('id')
table.integer('surveyquestion_id')
.unsigned().index()
.references('id').inTable('surveyquestions')
.onDelete('CASCADE')
.onUpdate('CASCADE')
table.string('value')
table.integer('surveychoice_id')
.unsigned().index()
.references('id').inTable('surveychoices')
.onDelete('CASCADE')
.onUpdate('CASCADE')
table.integer('surveysubmission_id')
.unsigned().index()
.references('id').inTable('surveysubmissions')
.onDelete('CASCADE')
.onUpdate('CASCADE')
})

exports.down = (knex, Promise) => knex.schema.dropTable('surveyanswers')
17 changes: 17 additions & 0 deletions migrations/20180327142119_create_hackathons_surveys_table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
exports.up = (knex, Promise) =>
knex.schema.createTable('hackathons_surveys', (table) => {
table.integer('hackathon_id')
.unsigned()
.references('id').inTable('hackathons')
.onDelete('CASCADE')
.onUpdate('CASCADE')
table.integer('survey_id')
.unsigned()
.references('id').inTable('surveys')
.onDelete('CASCADE')
.onUpdate('CASCADE')
table.primary(['hackathon_id', 'survey_id'])
})

exports.down = (knex, Promise) =>
knex.schema.dropTable('hackathons_surveys')
13 changes: 13 additions & 0 deletions migrations/20180327204704_remove_hackathons_table_survey.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
exports.up = (knex, Promise) =>
knex.schema.table('hackathons', table => {
table.dropColumn('survey_link')
table.dropColumn('survey_promo')
table.dropColumn('survey_prize')
})

exports.down = (knex, Promise) =>
knex.schema.table('hackathons', table => {
table.string('survey_link')
table.string('survey_promo')
table.string('survey_prize')
})
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"dependencies": {
"apollo-server-restify": "^1.3.2",
"applicationinsights": "^1.0.1",
"dataloader": "^1.3.0",
"dotenv": "^4.0.0",
"graphql": "^0.12.3",
"knex": "^0.14.2",
Expand Down
9 changes: 8 additions & 1 deletion seeds/000-delete-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@ const databases = [
'mentors_skills',
'hackathons_mentors',
'hackathons_technologies',
'hackathons_surveys',
'inquiries',
'azurecodes',
'surveyanswers',
'surveysubmissions',
'surveychoices',
'surveyquestions',
'students',
'surveys',
'hackathons',
'projects',
'sessions',
Expand All @@ -17,7 +23,7 @@ const databases = [
const truncateOrder = databases.reverse()

exports.seed = (knex, Promise) => Promise.each(databases.map((dbName) => knex(dbName).del()), () => {})

.then(() => console.log('everything is deleted'))
.then(() => Promise.all(truncateOrder.map(dbName => {
const seqName = `${dbName}_id_seq`
const sql = `
Expand All @@ -30,3 +36,4 @@ exports.seed = (knex, Promise) => Promise.each(databases.map((dbName) => knex(db
console.log(`${dbName} does not have auto_increment id`)
})
})))
.then(() => console.log('everything is truncated'))
10 changes: 2 additions & 8 deletions seeds/005-hackathons.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,14 @@ exports.seed = (knex, Promise) =>
start_date: '2018-02-23',
end_date: '2018-02-25',
bot_deployed: 'https://hackillinois-bot.azurewebsites.net',
bot_directline_key: 'abc',
survey_link: 'aka.ms/survey1',
survey_promo: 'Come and fill our survey at {survey_link} and win a {survey_prize}',
survey_prize: 'Hololens'
bot_directline_key: 'abc'
},
{
name: 'MHacks 2018',
slug: 'mhacks2018',
description: 'The hackathon that takes place in University of Michigan.',
start_date: '2018-09-20',
end_date: '2018-09-23',
bot_deployed: null,
survey_link: 'aka.ms/survey2',
survey_promo: 'Come and fill our awesome survey at {survey_link} and win a {survey_prize}',
survey_prize: 'XBox One'
bot_deployed: null
}
])
10 changes: 10 additions & 0 deletions seeds/065-surveys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const dbName = 'surveys'
exports.seed = (knex, Promise) =>
knex(dbName).insert([
{
title: 'Student Survey',
prize: 'A GoPro 5',
link: 'https://aka.ms/surveylink',
promo: 'Take our student survey for a chance to win a GoPro 5!'
}
])
25 changes: 25 additions & 0 deletions seeds/070-surveyquestions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const dbName = 'surveyquestions'
exports.seed = (knex, Promise) =>
knex(dbName).insert([
{
prompt: 'What technology do you want to work on? (select one)',
type: 'CHOICE',
survey_id: 1,
order: 1
}, {
prompt: 'What language do you want to work on? (select one)',
type: 'CHOICE',
survey_id: 1,
order: 2
}, {
prompt: 'What company do you want to work for the most? (select one)',
type: 'CHOICE',
survey_id: 1,
order: 3
}, {
prompt: 'Can you tell me a little more about your project?',
type: 'TEXT',
survey_id: 1,
order: 4
}
])
65 changes: 65 additions & 0 deletions seeds/075-surveychoices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
const dbName = 'surveychoices'
exports.seed = (knex, Promise) =>
knex(dbName).insert([
{
surveyquestion_id: 1,
value: 'Machine Learning',
order: 1
}, {
surveyquestion_id: 1,
value: 'Computer Vision',
order: 2
}, {
surveyquestion_id: 1,
value: 'Web Service',
order: 3
}, {
surveyquestion_id: 1,
value: 'Big Data',
order: 4
}, {
surveyquestion_id: 1,
value: 'Chat Bot',
order: 5
}, {
surveyquestion_id: 2,
value: 'Python',
order: 1
}, {
surveyquestion_id: 2,
value: 'Javascript',
order: 2
}, {
surveyquestion_id: 2,
value: 'C++',
order: 3
}, {
surveyquestion_id: 2,
value: 'C#',
order: 4
}, {
surveyquestion_id: 2,
value: 'Scala',
order: 5
}, {
surveyquestion_id: 2,
value: 'Java',
order: 6
}, {
surveyquestion_id: 3,
value: 'Amazon',
order: 1
}, {
surveyquestion_id: 3,
value: 'Microsoft',
order: 2
}, {
surveyquestion_id: 3,
value: 'Facebook',
order: 3
}, {
surveyquestion_id: 3,
value: 'Google',
order: 4
}
])
21 changes: 21 additions & 0 deletions seeds/077-surveysubmissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const dbName = 'surveysubmissions'
exports.seed = (knex, Promise) =>
knex(dbName).insert([
{
hackathon_id: 1,
survey_id: 1,
student_id: 1
}, {
hackathon_id: 1,
survey_id: 1,
student_id: 2
}, {
hackathon_id: 1,
survey_id: 1,
student_id: 3
}, {
hackathon_id: 1,
survey_id: 1,
student_id: 4
}
])
71 changes: 71 additions & 0 deletions seeds/080-surveyanswers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const dbName = 'surveyanswers'
exports.seed = (knex, Promise) =>
knex(dbName).insert([
{
surveyquestion_id: 1,
value: 'Jane',
surveychoice_id: null,
surveysubmission_id: 1
}, {
surveyquestion_id: 2,
value: 'Doe',
surveychoice_id: null,
surveysubmission_id: 1
}, {
surveyquestion_id: 3,
value: null,
surveychoice_id: 2,
surveysubmission_id: 1
},

{
surveyquestion_id: 1,
value: 'Bob',
surveychoice_id: null,
surveysubmission_id: 2
}, {
surveyquestion_id: 2,
value: 'Lee',
surveychoice_id: null,
surveysubmission_id: 2
}, {
surveyquestion_id: 3,
value: null,
surveychoice_id: 2,
surveysubmission_id: 2
},

{
surveyquestion_id: 1,
value: 'John',
surveychoice_id: null,
surveysubmission_id: 3
}, {
surveyquestion_id: 2,
value: 'Doe',
surveychoice_id: null,
surveysubmission_id: 3
}, {
surveyquestion_id: 3,
value: null,
surveychoice_id: 2,
surveysubmission_id: 3
},

{
surveyquestion_id: 1,
value: 'Alice',
surveychoice_id: null,
surveysubmission_id: 4
}, {
surveyquestion_id: 2,
value: 'Bae',
surveychoice_id: null,
surveysubmission_id: 4
}, {
surveyquestion_id: 3,
value: null,
surveychoice_id: 2,
surveysubmission_id: 4
}
])
Loading