Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
757 sql reformatting finetune sqlfluff (#765)
Browse files Browse the repository at this point in the history
closes #757
<!--
Check relevant points but **please do not remove entries**.
-->

## Basics

<!--
These points need to be fulfilled for every PR.
-->

- [x] I added a line to [/doc/CHANGELOG.md](/doc/CHANGELOG.md)
- [x] The PR is rebased with current master.
- [x] Details of what you changed are in commit messages.
- [x] References to issues, e.g. `close #X`, are in the commit messages.
- [ ] The buildserver is happy.

<!--
If you have any troubles fulfilling these criteria, please write about
the trouble as comment in the PR.
We will help you, but we cannot accept PRs that do not fulfill the
basics.
-->

## Checklist

<!--
For documentation fixes, spell checking, and similar none of these
points below need to be checked.
Otherwise please check these points when getting a PR done:
-->

- [x] I have installed and I am using [pre-commit
hooks](../doc/contrib/README.md#Hooks)
- [ ] I fully described what my PR does in the documentation
      (not in the PR description)
- [ ] I fixed all affected documentation
- [ ] I fixed the introduction tour
- [x] I wrote migrations in a way that they are compatible with already
present data
- [x] I fixed all affected decisions
- [ ] I added unit tests for my code
- [ ] I added code comments, logging, and assertions as appropriate
- [ ] I translated all strings visible to the user
- [ ] I mentioned [every code or
binary](https://github.com/ElektraInitiative/PermaplanT/blob/master/.reuse/dep5)
not directly written or done by me in [reuse
syntax](https://reuse.software/)
- [ ] I created left-over issues for things that are still to be done
- [x] Code is conforming to [our Architecture](/doc/architecture)
- [x] Code is conforming to [our Guidelines](/doc/guidelines)
      (exceptions are documented)
- [x] Code is consistent to [our Design Decisions](/doc/decisions)

## Review

<!--
Reviewers can copy&check the following to their review.
Also the checklist above can be used.
But also the PR creator should check these points when getting a PR
done:
-->

- [ ] I've tested the code
- [ ] I've read through the whole code
- [ ] Examples are well chosen and understandable
  • Loading branch information
markus2330 authored Aug 24, 2023
2 parents 899d476 + e2feeea commit 2c7e017
Show file tree
Hide file tree
Showing 27 changed files with 684 additions and 680 deletions.
5 changes: 3 additions & 2 deletions backend/.sqlfluff
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# https://docs.sqlfluff.com/en/stable/configuration.html
[sqlfluff]
dialect = postgres
max_line_length = 120

#enforce upper and lowercase
# Capitalization Rules
[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = upper
[sqlfluff:rules:capitalisation.identifiers]
Expand All @@ -12,4 +13,4 @@ extended_capitalisation_policy = lower
[sqlfluff:rules:capitalisation.literals]
capitalisation_policy = lower
[sqlfluff:rules:capitalisation.types]
extended_capitalisation_policy = upper
extended_capitalisation_policy = lower
10 changes: 5 additions & 5 deletions backend/migrations/2023-07-04-190000_base_layer/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
-- Please create a new migration instead.

CREATE TABLE base_layer_images (
id UUID PRIMARY KEY,
layer_id INTEGER NOT NULL,
path TEXT NOT NULL,
rotation REAL NOT NULL,
scale REAL NOT NULL,
id uuid PRIMARY KEY,
layer_id integer NOT NULL,
path text NOT NULL,
rotation real NOT NULL,
scale real NOT NULL,
FOREIGN KEY (layer_id) REFERENCES layers (id) ON DELETE CASCADE
);
24 changes: 12 additions & 12 deletions backend/migrations/2023-07-12-143111_user_data/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ CREATE TYPE membership AS ENUM (
);

CREATE TABLE users (
id UUID PRIMARY KEY,
salutation SALUTATION NOT NULL,
title TEXT,
country TEXT NOT NULL,
phone TEXT,
website TEXT,
organization TEXT,
experience EXPERIENCE,
membership MEMBERSHIP,
member_years INTEGER ARRAY,
member_since DATE,
permacoins INTEGER ARRAY
id uuid PRIMARY KEY,
salutation salutation NOT NULL,
title text,
country text NOT NULL,
phone text,
website text,
organization text,
experience experience,
membership membership,
member_years integer ARRAY,
member_since date,
permacoins integer ARRAY
);
22 changes: 11 additions & 11 deletions backend/migrations/2023-07-21-085933_gain_blossoms/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ CREATE TYPE track AS ENUM (
);

CREATE TABLE guided_tours (
user_id UUID PRIMARY KEY,
editor_tour_completed BOOLEAN NOT NULL DEFAULT false
user_id uuid PRIMARY KEY,
editor_tour_completed boolean NOT NULL DEFAULT false
);

CREATE TABLE blossoms (
title TEXT PRIMARY KEY,
description TEXT,
track TRACK,
icon TEXT,
is_seasonal BOOLEAN NOT NULL
title text PRIMARY KEY,
description text,
track track,
icon text,
is_seasonal boolean NOT NULL
);

CREATE TABLE gained_blossoms (
user_id UUID NOT NULL,
blossom TEXT NOT NULL,
times_gained INTEGER NOT NULL,
gained_date DATE NOT NULL,
user_id uuid NOT NULL,
blossom text NOT NULL,
times_gained integer NOT NULL,
gained_date date NOT NULL,
PRIMARY KEY (user_id, blossom)
);
2 changes: 1 addition & 1 deletion doc/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Syntax: `- short text describing the change _(Your Name)_`
- _()_
- _()_
- update `doc/database/hierarchy.md` to clarify how we render plant names _(temmey)_
- _()_
- updated sqlfluff config, remove unused .sql files _(temmey)_
- _()_
- _()_
- _()_
Expand Down
4 changes: 2 additions & 2 deletions doc/decisions/database_plant_hierarchy.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ Cons:
- We add "cultivar" as lowest rank.
- We remove the rank "subfamily".

For details on the schema see this [example SQL](example_migrations/normalized-plants-and-ranks/2023-04-07-130215_plant_relationships/up.sql)
Here are some [example queries](example_migrations/normalized-plants-and-ranks/example_queries.sql)
For details on the schema see this [example SQL](example_migrations/normalized-plants-and-ranks/2023-04-07-130215_plant_relationships/up.sql.md)
Here are some [example queries](example_migrations/normalized-plants-and-ranks/example_queries.sql.md)

## Rationale

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
DROP TABLE plant_relationships;
DROP TYPE relationship_kind;
ALTER TABLE plants
DROP COLUMN family_id,
DROP COLUMN subfamily_id,
DROP COLUMN genus_id,
DROP COLUMN species_id;
DROP TYPE taxonomic_rank;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CREATE TYPE taxonomic_rank AS ENUM ('family', 'subfamily', 'genus', 'species', 'variety');
ALTER TABLE plants
ADD COLUMN rank TAXONOMIC_RANK NOT NULL,
ADD COLUMN family_id INTEGER REFERENCES plants (id) NULL,
ADD COLUMN subfamily_id INTEGER REFERENCES plants (id) NULL,
ADD COLUMN genus_id INTEGER REFERENCES plants (id) NULL,
ADD COLUMN species_id INTEGER REFERENCES plants (id) NULL;

CREATE TYPE relationship_kind AS ENUM ('companion', 'antagonist', 'neutral');
CREATE TABLE plant_relationships (
id SERIAL PRIMARY KEY NOT NULL,
confidence INTEGER CHECK (confidence >= 0) NOT NULL,
kind relationship_kind NOT NULL,
left_plant_id INTEGER REFERENCES plants (id) NOT NULL,
right_plant_id INTEGER REFERENCES plants (id) NOT NULL
);
Loading

0 comments on commit 2c7e017

Please sign in to comment.