This commit is contained in:
vipg
2025-11-11 16:42:35 +08:00
parent a0ece129b8
commit 770f348952
3 changed files with 20 additions and 18 deletions

View File

@@ -11,8 +11,8 @@ $$ LANGUAGE plpgsql VOLATILE;
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'user_account') THEN
CREATE TABLE user_account (
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'account') THEN
CREATE TABLE account (
id UUID DEFAULT gen_random_uuid_v7() PRIMARY KEY NOT NULL,
user_id UUID NOT NULL,
account VARCHAR NOT NULL,
@@ -20,13 +20,13 @@ BEGIN
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TRIGGER update_user_account_updated_at
BEFORE UPDATE ON "user_account"
CREATE TRIGGER update_account_updated_at
BEFORE UPDATE ON "account"
FOR EACH ROW
EXECUTE FUNCTION update_account_modified_column();
RAISE NOTICE 'Created user_account table and trigger';
RAISE NOTICE 'Created account table and trigger';
ELSE
RAISE NOTICE 'user_account table already exists';
RAISE NOTICE 'account table already exists';
END IF;
END $$;