|
| 1 | +CREATE TYPE "skill_level" AS ENUM ( |
| 2 | + 'beginner', |
| 3 | + 'intermediate', |
| 4 | + 'expert', |
| 5 | + 'advanced' |
| 6 | +); |
| 7 | + |
| 8 | +CREATE TABLE "jobpost" ( |
| 9 | + "id" SERIAL PRIMARY KEY, |
| 10 | + "role" varchar, |
| 11 | + "job_type_id" int, |
| 12 | + "location" varchar, |
| 13 | + "tags" varchar, |
| 14 | + "description" varchar, |
| 15 | + "exp_required" int, |
| 16 | + "company_id" int, |
| 17 | + "link_to_apply" varchar, |
| 18 | + "email" varchar, |
| 19 | + "ctc_per_year" float8, |
| 20 | + "ctc_range_start" float8, |
| 21 | + "ctc_range_end" float8, |
| 22 | + "hourly_rate" float8, |
| 23 | + "created_at" timestamp, |
| 24 | + "updated_at" timestamp |
| 25 | +); |
| 26 | + |
| 27 | +CREATE TABLE "job_type" ( |
| 28 | + "id" SERIAL PRIMARY KEY, |
| 29 | + "name" varchar |
| 30 | +); |
| 31 | + |
| 32 | +CREATE TABLE "jobpost_skill" ( |
| 33 | + "id" SERIAL PRIMARY KEY, |
| 34 | + "jobpost_id" int, |
| 35 | + "skill_id" int |
| 36 | +); |
| 37 | + |
| 38 | +CREATE TABLE "user" ( |
| 39 | + "id" SERIAL PRIMARY KEY, |
| 40 | + "first_name" varchar, |
| 41 | + "last_name" varchar, |
| 42 | + "email" varchar, |
| 43 | + "is_admin" boolean, |
| 44 | + "user_type" varchar, |
| 45 | + "phone_no" int, |
| 46 | + "gender" varchar, |
| 47 | + "heighest_education" varchar, |
| 48 | + "created_at" timestamp, |
| 49 | + "current_ctc" int, |
| 50 | + "expected_ctc" int, |
| 51 | + "notice_period" varchar, |
| 52 | + "resume" blob, |
| 53 | + "website" varchar, |
| 54 | + "github" varchar, |
| 55 | + "linkedin" varchar, |
| 56 | + "preferred_location" varchar, |
| 57 | + "total_experience" int, |
| 58 | + "age" int |
| 59 | +); |
| 60 | + |
| 61 | +CREATE TABLE "user_employer" ( |
| 62 | + "id" SERIAL PRIMARY KEY, |
| 63 | + "user_id" int, |
| 64 | + "employer_id" int, |
| 65 | + "is_current_employer" boolean, |
| 66 | + "designation" varchar, |
| 67 | + "start_date" datetime, |
| 68 | + "end_date" datetime, |
| 69 | + "key_job_responsibilities" varchar |
| 70 | +); |
| 71 | + |
| 72 | +CREATE TABLE "user_employer_project" ( |
| 73 | + "id" SERIAL PRIMARY KEY, |
| 74 | + "user_employer_id" int, |
| 75 | + "name" varchar, |
| 76 | + "description" varchar, |
| 77 | + "start_date" datetime, |
| 78 | + "end_date" datetime, |
| 79 | + "team_size" int |
| 80 | +); |
| 81 | + |
| 82 | +CREATE TABLE "user_employer_project_skill" ( |
| 83 | + "id" SERIAL PRIMARY KEY, |
| 84 | + "user_employer_project_id" int, |
| 85 | + "skill_id" int |
| 86 | +); |
| 87 | + |
| 88 | +CREATE TABLE "company" ( |
| 89 | + "id" SERIAL PRIMARY KEY, |
| 90 | + "name" varchar, |
| 91 | + "logo" blob, |
| 92 | + "website" varchar |
| 93 | +); |
| 94 | + |
| 95 | +CREATE TABLE "skill" ( |
| 96 | + "id" SERIAL PRIMARY KEY, |
| 97 | + "name" varchar |
| 98 | +); |
| 99 | + |
| 100 | +CREATE TABLE "user_skill" ( |
| 101 | + "id" SERIAL PRIMARY KEY, |
| 102 | + "user_id" int, |
| 103 | + "skill_id" int, |
| 104 | + "level" skill_level, |
| 105 | + "last_used" varchar |
| 106 | +); |
| 107 | + |
| 108 | +CREATE TABLE "certifcation" ( |
| 109 | + "id" SERIAL PRIMARY KEY, |
| 110 | + "name" varchar, |
| 111 | + "description" varchar, |
| 112 | + "certifying_body" varchar |
| 113 | +); |
| 114 | + |
| 115 | +CREATE TABLE "user_certification" ( |
| 116 | + "id" SERIAL PRIMARY KEY, |
| 117 | + "user_id" int, |
| 118 | + "certifcation_id" int |
| 119 | +); |
| 120 | + |
| 121 | +CREATE TABLE "education" ( |
| 122 | + "id" SERIAL PRIMARY KEY, |
| 123 | + "name" varchar, |
| 124 | + "stream" varchar |
| 125 | +); |
| 126 | + |
| 127 | +CREATE TABLE "user_education" ( |
| 128 | + "id" SERIAL PRIMARY KEY, |
| 129 | + "user_id" int, |
| 130 | + "education_id" int, |
| 131 | + "is_current_education" boolean, |
| 132 | + "start_date" datetime, |
| 133 | + "end_date" datetime, |
| 134 | + "percentage" float8, |
| 135 | + "institute_id" int, |
| 136 | + "specialization" varchar |
| 137 | +); |
| 138 | + |
| 139 | +CREATE TABLE "education_institute" ( |
| 140 | + "id" SERIAL PRIMARY KEY, |
| 141 | + "name" varchar, |
| 142 | + "university" varchar |
| 143 | +); |
| 144 | + |
| 145 | +ALTER TABLE "jobpost" ADD FOREIGN KEY ("job_type_id") REFERENCES "job_type" ("id"); |
| 146 | + |
| 147 | +ALTER TABLE "jobpost" ADD FOREIGN KEY ("company_id") REFERENCES "company" ("id"); |
| 148 | + |
| 149 | +ALTER TABLE "jobpost_skill" ADD FOREIGN KEY ("jobpost_id") REFERENCES "jobpost" ("id"); |
| 150 | + |
| 151 | +ALTER TABLE "jobpost_skill" ADD FOREIGN KEY ("skill_id") REFERENCES "skill" ("id"); |
| 152 | + |
| 153 | +ALTER TABLE "user_employer" ADD FOREIGN KEY ("user_id") REFERENCES "user" ("id"); |
| 154 | + |
| 155 | +ALTER TABLE "user_employer" ADD FOREIGN KEY ("employer_id") REFERENCES "company" ("id"); |
| 156 | + |
| 157 | +ALTER TABLE "user_employer_project" ADD FOREIGN KEY ("user_employer_id") REFERENCES "user_employer" ("id"); |
| 158 | + |
| 159 | +ALTER TABLE "user_employer_project_skill" ADD FOREIGN KEY ("user_employer_project_id") REFERENCES "user_employer_project" ("id"); |
| 160 | + |
| 161 | +ALTER TABLE "user_employer_project_skill" ADD FOREIGN KEY ("skill_id") REFERENCES "skill" ("id"); |
| 162 | + |
| 163 | +ALTER TABLE "user_skill" ADD FOREIGN KEY ("user_id") REFERENCES "user" ("id"); |
| 164 | + |
| 165 | +ALTER TABLE "user_skill" ADD FOREIGN KEY ("skill_id") REFERENCES "skill" ("id"); |
| 166 | + |
| 167 | +ALTER TABLE "user_certification" ADD FOREIGN KEY ("user_id") REFERENCES "user" ("id"); |
| 168 | + |
| 169 | +ALTER TABLE "user_certification" ADD FOREIGN KEY ("certifcation_id") REFERENCES "certifcation" ("id"); |
| 170 | + |
| 171 | +ALTER TABLE "user_education" ADD FOREIGN KEY ("user_id") REFERENCES "user" ("id"); |
| 172 | + |
| 173 | +ALTER TABLE "user_education" ADD FOREIGN KEY ("education_id") REFERENCES "education" ("id"); |
| 174 | + |
| 175 | +ALTER TABLE "user_education" ADD FOREIGN KEY ("institute_id") REFERENCES "education_institute" ("id"); |
| 176 | + |
| 177 | +ALTER TABLE "user_skill" ADD FOREIGN KEY ("id") REFERENCES "user_skill" ("user_id"); |
0 commit comments