chore: update migration - add goose down to migration

This commit is contained in:
Sosokker 2025-03-12 17:12:48 +07:00
parent 3d020fcd58
commit 4e601daa6c
4 changed files with 36 additions and 2 deletions

View File

@ -10,4 +10,8 @@ CREATE TABLE users (
is_active BOOLEAN NOT NULL DEFAULT TRUE
);
CREATE UNIQUE INDEX idx_users_uuid ON users(uuid);
CREATE UNIQUE INDEX idx_users_uuid ON users(uuid);
-- +goose Down
DROP INDEX IF EXISTS idx_users_uuid;
DROP TABLE IF EXISTS users;

View File

@ -66,3 +66,12 @@ CREATE TABLE croplands (
CONSTRAINT fk_cropland_farm FOREIGN KEY (farm_id) REFERENCES farms(uuid) ON DELETE CASCADE,
CONSTRAINT fk_cropland_plant FOREIGN KEY (plant_id) REFERENCES plants(uuid) ON DELETE CASCADE
);
-- +goose Down
DROP TABLE IF EXISTS croplands;
DROP TABLE IF EXISTS farms;
DROP TABLE IF EXISTS plants;
DROP TABLE IF EXISTS harvest_units;
DROP TABLE IF EXISTS soil_conditions;
DROP TABLE IF EXISTS light_profiles;

View File

@ -1,2 +1,6 @@
-- +goose Up
ALTER TABLE farms DROP COLUMN plant_types;
ALTER TABLE farms DROP COLUMN plant_types;
-- +goose Down
ALTER TABLE farms
ADD COLUMN plant_types UUID[];

View File

@ -0,0 +1,17 @@
-- +goose Up
ALTER TABLE farms
ADD COLUMN farm_type TEXT,
ADD COLUMN total_size TEXT;
ALTER TABLE farms
ALTER COLUMN lat TYPE DOUBLE PRECISION USING lat[1],
ALTER COLUMN lon TYPE DOUBLE PRECISION USING lon[1];
-- +goose Down
ALTER TABLE farms
ALTER COLUMN lat TYPE DOUBLE PRECISION[] USING ARRAY[lat],
ALTER COLUMN lon TYPE DOUBLE PRECISION[] USING ARRAY[lon];
ALTER TABLE farms
DROP COLUMN farm_type,
DROP COLUMN total_size;