Skip to content

Add migration scripts for some tables#29

Closed
bickelj wants to merge 2 commits into
mainfrom
8-add-first-several-tables
Closed

Add migration scripts for some tables#29
bickelj wants to merge 2 commits into
mainfrom
8-add-first-several-tables

Conversation

@bickelj

@bickelj bickelj commented Jul 12, 2022

Copy link
Copy Markdown
Contributor

These are the minimal tables in the draft entity relationship diagram
required to start working with opportunities and applications.

Issue #8 Set up schema

Co-authored by: Daniel Schultz slifty@gmail.com

These are the minimal tables in the draft entity relationship diagram
required to start working with opportunities and applications.

Issue #8 Set up schema

Co-authored by: Daniel Schultz <slifty@gmail.com>
@bickelj bickelj requested a review from slifty July 12, 2022 01:38
@bickelj

bickelj commented Jul 12, 2022

Copy link
Copy Markdown
Contributor Author

I will come back to the GitHub migrate action in the morning, but I encourage you to see if this works locally.

@slifty

slifty commented Jul 12, 2022

Copy link
Copy Markdown
Member

I would love to see these added in the context of their use -- that way we avoid situations where we realize the table definition doesn't work for our API use case.

Now that we have all of the layers set up, what do you think about focusing on implementing a specific endpoint top-to-bottom (migration + route + buisness logic)?

Comment thread src/database/index.ts Outdated
Comment thread src/database/index.ts Outdated
@bickelj

bickelj commented Jul 12, 2022

Copy link
Copy Markdown
Contributor Author

I would love to see these added in the context of their use -- that way we avoid situations where we realize the table definition doesn't work for our API use case.

Now that we have all of the layers set up, what do you think about focusing on implementing a specific endpoint top-to-bottom (migration + route + buisness logic)?

That is also fine. I don't think it would change the order of development, meaning I would still need a database to write to in order to develop routes, handlers, etc. Also in the spirit of Continuous Integration we don't want long-lived branches. But yes, I agree that it will affect the design by making sure it can be used in the context it's supposed to be used, etc. Makes sense.

These tables are the minimal ones needed for opportunities and applications, i.e. the two endpoints described in the present draft OpenAPI document.

@bickelj bickelj mentioned this pull request Jul 12, 2022
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #29 (f5c08ac) into main (62920b0) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main       #29   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines           20        20           
=========================================
  Hits            20        20           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 62920b0...f5c08ac. Read the comment docs.

Comment thread src/database/migrations/0001-create-canonical_fields.sql
@bickelj

bickelj commented Jul 12, 2022

Copy link
Copy Markdown
Contributor Author

I forgot to mention why I did bigint: I guess I prefer the ids to be bigint so we have the least chance of ever rolling over. I know 2 billion is a "lot" but there are dbs out there where even bigint rolls over. The other thing I did was try to align the columns largest to smallest, so it goes 8 bytes (id), 8 bytes (timestamp), smaller than 8 bytes, smaller still, etc. That's just for space efficiency and probably premature optimization. Then again you cannot really go back and re-align them, I don't think, so may as well do it now.

@bickelj

bickelj commented Jul 12, 2022

Copy link
Copy Markdown
Contributor Author

I think I already mentioned a "why" on the varchar: it's the same type as text when the character limit is not specified, while also making it more portable/iso/ansi. Again not a big deal either way, because it looks like we're firmly postgres and that's good, but just explaining why.

@bickelj

bickelj commented Jul 12, 2022

Copy link
Copy Markdown
Contributor Author

I also realize on delete cascade is controversial. I am OK with leaving it out, but I would rather have my delete work when I call it instead of having to go through each and every table. Using delete should raise alarm bells and be very rare anyway.

@bickelj

bickelj commented Jul 12, 2022

Copy link
Copy Markdown
Contributor Author

One more thing to consider is whether to make them more idempotent, e.g. create table if not exists ... rather than create table .... The docs recommended idempotence. Liquibase has a concept of preconditions built-in, I didn't check to see if this tool has the same, but it's along the same lines conceptually.

@slifty

slifty commented Jul 21, 2022

Copy link
Copy Markdown
Member

I pulled the canonical_fields migration over to #55!

@slifty

slifty commented Nov 29, 2022

Copy link
Copy Markdown
Member

I think we can close this as well; we have a good migrations pattern (and can always reference this PR even after it's closed)

@slifty slifty closed this Nov 29, 2022
@slifty slifty deleted the 8-add-first-several-tables branch November 1, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants