Skip to content

Commit

Permalink
goal lox
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeMaster482 committed Dec 1, 2023
1 parent 106ac95 commit b7e6860
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions build/schema/initdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,32 @@ CREATE TABLE IF NOT EXISTS TransactionCategory (
PRIMARY KEY (transaction_id, category_id)
);

CREATE TABLE IF NOT EXISTS goal (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
user_id UUID REFERENCES "user"(user_id) NOT NULL,
"name" TEXT CHECK(LENGTH("name") <= 50) NOT NULL,
"description" TEXT DEFAULT '' CHECK(LENGTH("description") <= 255),
"target" NUMERIC(10,2) NOT NULL,
"date" DATE,
created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--CREATE TABLE IF NOT EXISTS goal (
-- id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
-- user_id UUID REFERENCES "user"(user_id) NOT NULL,
-- "name" TEXT CHECK(LENGTH("name") <= 50) NOT NULL,
-- "description" TEXT DEFAULT '' CHECK(LENGTH("description") <= 255),
-- "target" NUMERIC(10,2) NOT NULL,
-- "date" DATE,
-- created_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
-- updated_at TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL
--);

--========================================================================

CREATE OR REPLACE FUNCTION public.moddatetime()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = NOW();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE OR REPLACE TRIGGER modify_updated_at
BEFORE UPDATE
ON goal
FOR EACH ROW
EXECUTE PROCEDURE public.moddatetime(updated_at);
--CREATE OR REPLACE FUNCTION public.moddatetime()
-- RETURNS TRIGGER AS $$
--BEGIN
-- NEW.updated_at = NOW();
-- RETURN NEW;
--END;
--$$ LANGUAGE plpgsql;
--
--CREATE OR REPLACE TRIGGER modify_updated_at
-- BEFORE UPDATE
-- ON goal
-- FOR EACH ROW
--EXECUTE PROCEDURE public.moddatetime(updated_at);

--========================================================================

Expand Down

0 comments on commit b7e6860

Please sign in to comment.