diff --git a/characteristics.go b/characteristics.go index 51c70a5..3bc9605 100644 --- a/characteristics.go +++ b/characteristics.go @@ -24,6 +24,9 @@ type CharacteristicBase struct { CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` + CreatedBy int64 `db:"created_by" json:"createdBy"` + UpdatedBy int64 `db:"updated_by" json:"updatedBy"` + DeletedBy NullInt64 `db:"deleted_by" json:"deletedBy"` } type Characteristic struct { diff --git a/measurements.go b/measurements.go index e06cbfc..b63f254 100644 --- a/measurements.go +++ b/measurements.go @@ -35,6 +35,8 @@ type MeasurementBase struct { TestMethodId NullInt64 `db:"test_method_id" json:"-"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` + CreatedBy int64 `db:"created_by" json:"createdBy"` + UpdatedBy int64 `db:"updated_by" json:"updatedBy"` } // Measurement & MeasurementJSON(s) are what ember expects to see diff --git a/migrations/00004_AddStrain_up.sql b/migrations/00004_AddStrain_up.sql index 3b84484..00f9350 100644 --- a/migrations/00004_AddStrain_up.sql +++ b/migrations/00004_AddStrain_up.sql @@ -10,15 +10,20 @@ CREATE TABLE strains ( genbank TEXT NULL, isolated_from TEXT NULL, notes TEXT NULL, - author_id BIGINT NOT NULL, created_at TIMESTAMP WITH TIME ZONE NOT NULL, updated_at TIMESTAMP WITH TIME ZONE NOT NULL, deleted_at TIMESTAMP WITH TIME ZONE NULL, + created_by BIGINT NOT NULL, + updated_by BIGINT NOT NULL, + deleted_by BIGINT NULL, + CONSTRAINT strain_pkey PRIMARY KEY (id), FOREIGN KEY (species_id) REFERENCES species(id), - FOREIGN KEY (author_id) REFERENCES users(id) + FOREIGN KEY (created_by) REFERENCES users(id), + FOREIGN KEY (updated_by) REFERENCES users(id), + FOREIGN KEY (deleted_by) REFERENCES users(id) ); CREATE INDEX species_id_idx ON strains (species_id); diff --git a/migrations/00006_AddCharacteristics_up.sql b/migrations/00006_AddCharacteristics_up.sql index aeab85e..86802cb 100644 --- a/migrations/00006_AddCharacteristics_up.sql +++ b/migrations/00006_AddCharacteristics_up.sql @@ -10,8 +10,15 @@ CREATE TABLE characteristics ( updated_at TIMESTAMP WITH TIME ZONE NOT NULL, deleted_at TIMESTAMP WITH TIME ZONE NULL, + created_by BIGINT NOT NULL, + updated_by BIGINT NOT NULL, + deleted_by BIGINT NULL, + CONSTRAINT characteristics_pkey PRIMARY KEY (id), - FOREIGN KEY (characteristic_type_id) REFERENCES characteristic_types(id) + FOREIGN KEY (characteristic_type_id) REFERENCES characteristic_types(id), + FOREIGN KEY (created_by) REFERENCES users(id), + FOREIGN KEY (updated_by) REFERENCES users(id), + FOREIGN KEY (deleted_by) REFERENCES users(id) ); CREATE INDEX characteristic_type_id_idx ON characteristics (characteristic_type_id); diff --git a/migrations/00010_AddMeasurements_up.sql b/migrations/00010_AddMeasurements_up.sql index ef48b2e..9d7e52b 100644 --- a/migrations/00010_AddMeasurements_up.sql +++ b/migrations/00010_AddMeasurements_up.sql @@ -16,6 +16,9 @@ CREATE TABLE measurements ( created_at TIMESTAMP WITH TIME ZONE NOT NULL, updated_at TIMESTAMP WITH TIME ZONE NOT NULL, + created_by BIGINT NOT NULL, + updated_by BIGINT NOT NULL, + CONSTRAINT strainscharmeasurements_pkey PRIMARY KEY (id), FOREIGN KEY (strain_id) REFERENCES strains(id), FOREIGN KEY (characteristic_id) REFERENCES characteristics(id), @@ -37,7 +40,9 @@ CREATE TABLE measurements ( AND txt_value IS NOT NULL AND num_value IS NULL AND confidence_interval IS NULL - AND unit_type_id IS NULL)) + AND unit_type_id IS NULL)), + FOREIGN KEY (created_by) REFERENCES users(id), + FOREIGN KEY (updated_by) REFERENCES users(id) ); CREATE INDEX strain_id_idx ON measurements (strain_id); diff --git a/strains.go b/strains.go index 9a69c14..1215e5e 100644 --- a/strains.go +++ b/strains.go @@ -29,10 +29,12 @@ type StrainBase struct { Genbank NullString `db:"genbank" json:"genbank"` IsolatedFrom NullString `db:"isolated_from" json:"isolatedFrom"` Notes NullString `db:"notes" json:"notes"` - AuthorId int64 `db:"author_id" json:"author"` CreatedAt time.Time `db:"created_at" json:"createdAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` DeletedAt NullTime `db:"deleted_at" json:"deletedAt"` + CreatedBy int64 `db:"created_by" json:"createdBy"` + UpdatedBy int64 `db:"updated_by" json:"updatedBy"` + DeletedBy NullInt64 `db:"deleted_by" json:"deletedBy"` } // Strain & StrainJSON(s) are what ember expects to see