-
Notifications
You must be signed in to change notification settings - Fork 4
Add migration scripts for some tables #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| create table canonical_fields ( | ||
| id bigint primary key generated always as identity, | ||
| created_at timestamp with time zone not null default now(), | ||
| label varchar not null, | ||
| short_code varchar not null, | ||
| field_type varchar not null | ||
| ); | ||
|
|
||
| comment on table canonical_fields is | ||
| 'Canonical fields are those fields that are unique across organizations.'; | ||
| comment on column canonical_fields.label is 'The description of the field'; | ||
| comment on column canonical_fields.short_code is 'The short name of the field'; | ||
| comment on column canonical_fields.field_type is 'The data type of the field'; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| create table applicants ( | ||
| id bigint primary key generated always as identity, | ||
| created_at timestamp with time zone not null default now(), | ||
| external_id varchar not null, | ||
| opted_in boolean not null default false | ||
| ); | ||
|
|
||
| comment on table applicants is | ||
| 'Applicants submit applications for (funding) opportunities.'; | ||
| comment on column applicants.external_id is | ||
| 'The external identifier, not necessarily unique across organizations.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| create table opportunities ( | ||
| id bigint primary key generated always as identity, | ||
| created_at timestamp with time zone not null default now(), | ||
| title varchar not null | ||
| ); | ||
|
|
||
| comment on table opportunities is | ||
| 'Funding opportunities such as available grants or awards.'; | ||
| comment on column opportunities.title is | ||
| 'The external identifier; not necessarily unique across organizations.'; |
11 changes: 11 additions & 0 deletions
11
src/database/migrations/0004-create-application_schemas.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| create table application_schemas ( | ||
| id bigint primary key generated always as identity, | ||
| created_at timestamp with time zone not null default now(), | ||
| opportunity_id bigint not null | ||
| references opportunities (id) on delete cascade, | ||
| version smallint not null generated by default as identity, | ||
| constraint unique_opportunity_id_version unique (opportunity_id, version) | ||
| ); | ||
|
|
||
| comment on table application_schemas is | ||
| 'A set of canonical fields for one opportunity.' |
18 changes: 18 additions & 0 deletions
18
src/database/migrations/0005-create-application_schema_fields.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| create table application_schema_fields ( | ||
| id bigint primary key generated always as identity, | ||
| created_at timestamp with time zone not null default now(), | ||
| application_schema_id bigint not null | ||
| references application_schemas (id) on delete cascade, | ||
| canonical_field_id bigint not null | ||
| references canonical_fields (id) on delete cascade, | ||
| position int not null, | ||
| label varchar not null, | ||
| constraint unique_application_schema_id_canonical_field_id unique(application_schema_id, canonical_field_id) | ||
| ); | ||
|
|
||
| comment on table application_schema_fields is | ||
| 'An available field in an application schema.'; | ||
| comment on column application_schema_fields.position is | ||
| 'The relative order of this field within its application schema.'; | ||
| comment on column application_schema_fields.label is | ||
| 'The name of this field within its application schema. These may vary between application schemas, opportunities, or organizations but many of these may refer to one canonical field.'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| create table applications ( | ||
| id bigint primary key generated always as identity, | ||
| created_at timestamp with time zone not null default now(), | ||
| opportunity_id bigint not null | ||
| references opportunities (id) on delete cascade, | ||
| applicant_id bigint not null | ||
| references applicants (id) on delete cascade | ||
| ); | ||
|
|
||
| comment on table applications is | ||
| 'A submission to an opportunity for funding.'; |
17 changes: 17 additions & 0 deletions
17
src/database/migrations/0007-create-application_versions.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| create table application_versions ( | ||
| id bigint primary key generated always as identity, | ||
| created_at timestamp with time zone not null default now(), | ||
| application_id bigint not null | ||
| references applications (id) on delete cascade, | ||
| application_schema_id bigint not null | ||
| references application_schemas (id) on delete cascade, | ||
| version int not null, | ||
| constraint unique_application_id_version unique (application_id, version) | ||
| ); | ||
|
|
||
| comment on table application_versions is | ||
| 'One instance or version of a filled-out application.'; | ||
| comment on column application_versions.application_schema_id is | ||
| 'The application schema for which this application was filled out.'; | ||
| comment on column application_versions.version is | ||
| 'When there are updates to an application, higher versions are used.'; |
17 changes: 17 additions & 0 deletions
17
src/database/migrations/0008-create-application_field_values.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| create table application_field_values ( | ||
| id bigint primary key generated always as identity, | ||
| created_at timestamp with time zone not null default now(), | ||
| application_version_id bigint not null | ||
| references application_versions (id) on delete cascade, | ||
| application_schema_field_id bigint not null | ||
| references application_schema_fields (id) on delete cascade, | ||
| position int not null default 0, | ||
| field_value varchar not null, | ||
| constraint unique_application_version_id_application_schema_field_id_position | ||
| unique(application_version_id, application_schema_field_id, position) | ||
| ); | ||
|
|
||
| comment on table application_field_values is | ||
| 'A filled-out field value in an application.'; | ||
| comment on column application_field_values.position is | ||
| 'When a field allows multiple responses, use additional position values.'; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.