1

I am currently working on a small web-app stored in a monorepo and using PSQL as database (hosted on GCP). It's my first time working for a web app and I have to create a lot of tables manually such as using this script to create the positions tables:

CREATE TABLE PUBLIC.positions
  (
     position_id  INTEGER NOT NULL GENERATED always AS IDENTITY,
     x_pos        INTEGER NULL,
     y_pos        INTEGER NULL,
     is_empty     BOOLEAN NULL,
     crop_type_id INTEGER NULL
  );

ALTER TABLE PUBLIC.positions
  ADD CONSTRAINT positions_pkey PRIMARY KEY (position_id);

My question is the following, should I save that table creation SQL code somewhere? If so, are there any good practices for naming and structuring?

2
  • 2
    I'd suggest looking into a schema version management tool - see this related post on StackOverflow - stackoverflow.com/questions/55837863/… Commented Aug 13, 2022 at 8:30
  • Thank you, seems an interesting topic and I did not know all of those tools were available Commented Aug 13, 2022 at 8:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.