Skip to content

Latest commit

 

History

History
24 lines (21 loc) · 1.19 KB

how-to-add-a-new-table.md

File metadata and controls

24 lines (21 loc) · 1.19 KB
  1. Open migrations/20211019221200_init_db.sql
  2. Add your new table schema in the file, between the -- +goose Up \n -- +goose StatementBegin and -- +goose StatementEnd lines Example:
CREATE TABLE IF NOT EXISTS <your_new_table> (
  id BIGSERIAL NOT NULL,
/*
	... Some fields
*/
  createdat DATE,
  updatedat DATE
);
  1. Add a drop table statement -- +goose Down \n -- +goose StatementBegin and -- +goose StatementEnd lines Example:
DROP TABLE IF EXISTS <your_new_table>;
  1. Create a fixture file <your_new_table>.sql for that will be used to populate your table in this location. Note: You can use mockaroo to generate the fixture data.

  2. Add the ../../fixtures/postgres/sql/<your_new_table>.sql in the appropriate position on that sql_file_ordered.txt file. This is used to specify the order in which your sql fixtures files will be applied to the Database.