{"size": 1294, "ext": "js", "max_stars_repo_path": "data/migrations/20200823222617_v1.js", "max_stars_repo_name": "Dev-Desk-queque/backend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "data/migrations/20200823222617_v1.js", "max_issues_repo_name": "Dev-Desk-queque/backend", "max_issues_repo_issues_event_min_datetime": "2020-08-24T17:55:25.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-27T18:54:47.000Z", "max_forks_repo_path": "data/migrations/20200823222617_v1.js", "max_forks_repo_name": "Dev-Desk-queque/backend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 15, "max_forks_count": null, "avg_line_length": 24.8846153846, "max_line_length": 49, "alphanum_fraction": 0.6306027821}
exports.up = function (knex) {
	return knex.schema
		.createTable("accounts", (tbl) => {
			tbl.increments("id"); // Primary Key
			tbl.string("username").notNullable().unique();
			tbl.string("password").notNullable();
			tbl.boolean("is_student");
			tbl.boolean("is_helper");
		})
		.createTable("questions", (tbl) => {
			tbl.increments("id"); // Primary Key
			tbl.boolean("is_resolved");
			tbl
				.integer("question_user_id")
				.unsigned()
				.notNullable()
				.references("accounts.id")
				.onDelete("CASCADE")
				.onUpdate("CASCADE");
			tbl.text("topic").notNullable();
			tbl.text("question").notNullable();
			tbl.text("what_I_tried");
			tbl.text("code_language");
		})
		.createTable("answers", (tbl) => {
			tbl.increments("id"); // Primary Key
			tbl
				.integer("question_id")
				.unsigned()
				.notNullable()
				.references("questions.id")
				.onDelete("CASCADE")
				.onUpdate("CASCADE");
			tbl
				.integer("answer_user_id")
				.unsigned()
				.notNullable()
				.references("accounts.id")
				.onDelete("CASCADE")
				.onUpdate("CASCADE");
			tbl.text("answer");
		});
};

exports.down = function (knex) {
	return knex.schema
		.dropTableIfExists("answers")
		.dropTableIfExists("questions")
		.dropTableIfExists("users")
		.dropTableIfExists("accounts");
};
