Remove unnessesary id columns from relation tables.

This commit is contained in:
Rasmus Kaj 2023-02-27 00:31:34 +01:00
parent 8ef1f0820a
commit 31c5823464
5 changed files with 22 additions and 8 deletions

View File

@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased
* Removed unnessesary id columns from relation tables.
## Release 0.12.0 (2023-02-26)
* Database access is now async (PR #10).

View File

@ -0,0 +1,6 @@
alter table photo_tags drop constraint photo_tags_pkey;
alter table photo_tags add column id serial primary key;
alter table photo_people drop constraint photo_people_pkey;
alter table photo_people add column id serial primary key;
alter table photo_places drop constraint photo_places_pkey;
alter table photo_places add column id serial primary key;

View File

@ -0,0 +1,8 @@
alter table photo_tags drop column id;
alter table photo_tags add primary key (photo_id, tag_id);
alter table photo_people drop column id;
alter table photo_people add primary key (photo_id, person_id);
alter table photo_places drop column id;
alter table photo_places add primary key (photo_id, place_id);

View File

@ -329,7 +329,6 @@ impl Facet for Person {
#[derive(Debug, Clone, Queryable)]
pub struct PhotoPerson {
pub id: i32,
pub photo_id: i32,
pub person_id: i32,
}
@ -355,7 +354,6 @@ impl Facet for Place {
#[derive(Debug, Clone, Queryable)]
pub struct PhotoPlace {
pub id: i32,
pub photo_id: i32,
pub place_id: i32,
}

View File

@ -22,24 +22,21 @@ table! {
}
table! {
photo_people (id) {
id -> Int4,
photo_people (photo_id, person_id) {
photo_id -> Int4,
person_id -> Int4,
}
}
table! {
photo_places (id) {
id -> Int4,
photo_places (photo_id, place_id) {
photo_id -> Int4,
place_id -> Int4,
}
}
table! {
photo_tags (id) {
id -> Int4,
photo_tags (photo_id, tag_id) {
photo_id -> Int4,
tag_id -> Int4,
}