Skip to content

Commit

Permalink
change time types to bigint for epoch
Browse files Browse the repository at this point in the history
  • Loading branch information
juancwu committed Dec 15, 2024
1 parent 8fa99b6 commit 2ff298d
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions backend/.sqlc/migrations/20241215194302_initial_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ CREATE TABLE IF NOT EXISTS users (
password char(256) NOT NULL,
role user_role NOT NULL,
email_verified boolean NOT NULL DEFAULT false,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_at bigint NOT NULL DEFAULT extract(epoch from now()),
updated_at bigint NOT NULL DEFAULT extract(epoch from now()),
token_salt bytea UNIQUE NOT NULL DEFAULT gen_random_bytes(32)
);

CREATE TABLE IF NOT EXISTS verify_email_tokens (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
expires_at timestamp NOT NULL
created_at bigint NOT NULL DEFAULT extract(epoch from now()),
expires_at bigint NOT NULL
);

CREATE TABLE IF NOT EXISTS companies (
Expand All @@ -41,8 +41,8 @@ CREATE TABLE IF NOT EXISTS companies (
name varchar NOT NULL,
wallet_address varchar,
linkedin_url varchar NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
created_at bigint NOT NULL DEFAULT extract(epoch from now()),
updated_at bigint NOT NULL DEFAULT extract(epoch from now())
);

CREATE TABLE IF NOT EXISTS team_members (
Expand All @@ -54,8 +54,8 @@ CREATE TABLE IF NOT EXISTS team_members (
bio varchar NOT NULL,
linkedin_url varchar NOT NULL,
is_account_owner boolean NOT NULL DEFAULT false,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
created_at bigint NOT NULL DEFAULT extract(epoch from now()),
updated_at bigint NOT NULL DEFAULT extract(epoch from now())
);

CREATE TABLE IF NOT EXISTS projects (
Expand All @@ -64,25 +64,25 @@ CREATE TABLE IF NOT EXISTS projects (
title varchar NOT NULL,
description varchar,
status project_status NOT NULL DEFAULT 'draft',
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
created_at bigint NOT NULL DEFAULT extract(epoch from now()),
updated_at bigint NOT NULL DEFAULT extract(epoch from now())
);

CREATE TABLE IF NOT EXISTS project_questions (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
question varchar NOT NULL,
section varchar NOT NULL DEFAULT 'overall',
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
created_at bigint NOT NULL DEFAULT extract(epoch from now()),
updated_at bigint NOT NULL DEFAULT extract(epoch from now())
);

CREATE TABLE IF NOT EXISTS project_answers (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
question_id uuid NOT NULL REFERENCES project_questions(id),
answer varchar NOT NULL DEFAULT '',
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_at bigint NOT NULL DEFAULT extract(epoch from now()),
updated_at bigint NOT NULL DEFAULT extract(epoch from now()),
UNIQUE(project_id, question_id)
);

Expand All @@ -92,8 +92,8 @@ CREATE TABLE IF NOT EXISTS project_documents (
name varchar NOT NULL,
url varchar NOT NULL,
section varchar NOT NULL DEFAULT 'overall',
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
created_at bigint NOT NULL DEFAULT extract(epoch from now()),
updated_at bigint NOT NULL DEFAULT extract(epoch from now())
);

CREATE TABLE IF NOT EXISTS project_comments (
Expand All @@ -102,8 +102,8 @@ CREATE TABLE IF NOT EXISTS project_comments (
target_id uuid NOT NULL,
comment uuid NOT NULL,
commenter_id uuid NOT NULL REFERENCES users(id),
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
created_at bigint NOT NULL DEFAULT extract(epoch from now()),
updated_at bigint NOT NULL DEFAULT extract(epoch from now())
);

CREATE TABLE IF NOT EXISTS transactions (
Expand All @@ -121,7 +121,7 @@ CREATE TABLE IF NOT EXISTS transactions (
total_fee decimal(65,18),
status boolean NOT NULL,
nonce bigint NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
created_at bigint NOT NULL DEFAULT extract(epoch from now())
);

CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);
Expand Down Expand Up @@ -156,4 +156,4 @@ DROP TABLE IF EXISTS users;

DROP TYPE IF EXISTS project_status;
DROP TYPE IF EXISTS user_role;
-- +goose StatementEnd
-- +goose StatementEnd

0 comments on commit 2ff298d

Please sign in to comment.