Using struct attrs to match desired db schema
This commit is contained in:
parent
7fe5566edf
commit
7e74d672ba
6 changed files with 27 additions and 27 deletions
|
@ -5,9 +5,9 @@ CREATE TABLE users (
|
||||||
id BIGSERIAL NOT NULL,
|
id BIGSERIAL NOT NULL,
|
||||||
username CHARACTER VARYING(100),
|
username CHARACTER VARYING(100),
|
||||||
|
|
||||||
createdat TIMESTAMP WITH TIME ZONE,
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
updatedat TIMESTAMP WITH TIME ZONE,
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
deletedat TIMESTAMP WITH TIME ZONE,
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
CONSTRAINT users_pkey PRIMARY KEY (id)
|
CONSTRAINT users_pkey PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
CREATE TABLE genera (
|
CREATE TABLE genera (
|
||||||
id BIGSERIAL NOT NULL,
|
id BIGSERIAL NOT NULL,
|
||||||
genusname CHARACTER VARYING(100),
|
genus_name CHARACTER VARYING(100),
|
||||||
|
|
||||||
createdat TIMESTAMP WITH TIME ZONE,
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
updatedat TIMESTAMP WITH TIME ZONE,
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
deletedat TIMESTAMP WITH TIME ZONE,
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
CONSTRAINT genus_pkey PRIMARY KEY (id)
|
CONSTRAINT genus_pkey PRIMARY KEY (id)
|
||||||
);
|
);
|
||||||
|
@ -15,5 +15,5 @@ CREATE TABLE genera (
|
||||||
CREATE UNIQUE INDEX genusname_idx
|
CREATE UNIQUE INDEX genusname_idx
|
||||||
ON genera
|
ON genera
|
||||||
USING btree
|
USING btree
|
||||||
(genusname COLLATE pg_catalog."default");
|
(genus_name COLLATE pg_catalog."default");
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
CREATE TABLE species (
|
CREATE TABLE species (
|
||||||
id BIGSERIAL NOT NULL,
|
id BIGSERIAL NOT NULL,
|
||||||
genusid BIGINT NOT NULL,
|
genus_id BIGINT NOT NULL,
|
||||||
speciesname CHARACTER VARYING(100),
|
species_name CHARACTER VARYING(100),
|
||||||
|
|
||||||
createdat TIMESTAMP WITH TIME ZONE,
|
created_at TIMESTAMP WITH TIME ZONE,
|
||||||
updatedat TIMESTAMP WITH TIME ZONE,
|
updated_at TIMESTAMP WITH TIME ZONE,
|
||||||
deletedat TIMESTAMP WITH TIME ZONE,
|
deleted_at TIMESTAMP WITH TIME ZONE,
|
||||||
|
|
||||||
CONSTRAINT species_pkey PRIMARY KEY (id),
|
CONSTRAINT species_pkey PRIMARY KEY (id),
|
||||||
FOREIGN KEY (genusid) REFERENCES genera(id)
|
FOREIGN KEY (genus_id) REFERENCES genera(id)
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,10 +12,10 @@ import (
|
||||||
// A Genus is a high-level classifier in bactdb.
|
// A Genus is a high-level classifier in bactdb.
|
||||||
type Genus struct {
|
type Genus struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id,omitempty"`
|
||||||
GenusName string `json:"genus_name"`
|
GenusName string `db:"genus_name" json:"genus_name"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
DeletedAt time.Time `json:"deleted_at"`
|
DeletedAt time.Time `db:"deleted_at" json:"deleted_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GeneraService interacts with the genus-related endpoints in bactdb's API.
|
// GeneraService interacts with the genus-related endpoints in bactdb's API.
|
||||||
|
|
|
@ -12,11 +12,11 @@ import (
|
||||||
// A Species is a high-level classifier in bactdb.
|
// A Species is a high-level classifier in bactdb.
|
||||||
type Species struct {
|
type Species struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id,omitempty"`
|
||||||
GenusId int64 `json:"genus_id"`
|
GenusId int64 `db:"genus_id" json:"genus_id"`
|
||||||
SpeciesName string `json:"species_name"`
|
SpeciesName string `db:"species_name" json:"species_name"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
DeletedAt time.Time `json:"deleted_at"`
|
DeletedAt time.Time `db:"deleted_at" json:"deleted_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SpeciesService interacts with the species-related endpoints in bactdb's API.
|
// SpeciesService interacts with the species-related endpoints in bactdb's API.
|
||||||
|
|
|
@ -12,10 +12,10 @@ import (
|
||||||
// A User is a person that has administrative access to bactdb.
|
// A User is a person that has administrative access to bactdb.
|
||||||
type User struct {
|
type User struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id,omitempty"`
|
||||||
UserName string `sql:"size:100" json:"user_name"`
|
UserName string `json:"user_name"`
|
||||||
CreatedAt time.Time `json:"created_at"`
|
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||||
UpdatedAt time.Time `json:"updated_at"`
|
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||||
DeletedAt time.Time `json:"deleted_at"`
|
DeletedAt time.Time `db:"deleted_at" json:"deleted_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UsersService interacts with the user-related endpoints in bactdb's API.
|
// UsersService interacts with the user-related endpoints in bactdb's API.
|
||||||
|
|
Reference in a new issue