From 495746d6a19a64dd914a5c28029608cdbda9d3f1 Mon Sep 17 00:00:00 2001 From: eraden Date: Sun, 11 Feb 2024 21:03:09 +0100 Subject: [PATCH] Fix db and tests --- Cargo.lock | 1 + crates/squadron-api/src/extractors/user.rs | 19 -- .../src/http/api/authentication.rs | 8 +- .../api/authentication/change_password.rs | 32 +- .../api/authentication/forgot_password.rs | 22 +- .../http/api/authentication/reset_password.rs | 11 +- crates/squadron-contract/Cargo.toml | 1 + crates/squadron-contract/src/event_bus/mod.rs | 74 ++++- plane_db.sql | 284 +++++++++--------- 9 files changed, 263 insertions(+), 189 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b780fa..5d8f4ed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4186,6 +4186,7 @@ dependencies = [ name = "squadron-contract" version = "0.1.0" dependencies = [ + "async-trait", "bincode", "chrono", "deadpool-redis", diff --git a/crates/squadron-api/src/extractors/user.rs b/crates/squadron-api/src/extractors/user.rs index e956f09..aba7440 100644 --- a/crates/squadron-api/src/extractors/user.rs +++ b/crates/squadron-api/src/extractors/user.rs @@ -207,7 +207,6 @@ mod tests { #[actix_web::test] async fn bad_account_id() { create_app!(app, session, db); - let _user = create_user(db, "valid_extract_user", "QWEqwwe123@#$").await; let pair = session .store( AppClaims { @@ -245,24 +244,6 @@ mod tests { #[actix_web::test] async fn no_token() { create_app!(app, session, db); - let user = create_user(db, "valid_extract_user", "QWEqwwe123@#$").await; - let _pair = session - .store( - AppClaims { - expiration_time: (chrono::Utc::now() + chrono::Duration::days(100)) - .timestamp_millis(), - issued_at: 0, - subject: "999999999".into(), - audience: session::Audience::Web, - jwt_id: Uuid::new_v4(), - account_id: user.id, - not_before: 0, - }, - JwtTtl::new(actix_jwt_session::Duration::days(9999)), - RefreshTtl::new(actix_jwt_session::Duration::days(9999)), - ) - .await - .unwrap(); let req = test::TestRequest::default() // .insert_header((JWT_HEADER_NAME, pair.jwt.encode().unwrap())) .uri("/test") diff --git a/crates/squadron-api/src/http/api/authentication.rs b/crates/squadron-api/src/http/api/authentication.rs index 041093e..fd0db4e 100644 --- a/crates/squadron-api/src/http/api/authentication.rs +++ b/crates/squadron-api/src/http/api/authentication.rs @@ -243,14 +243,18 @@ pub struct EmailAllowComment { pub comment_after_domain_part: Option, } -pub fn random_password() -> String { +pub fn random_hex(len: usize) -> String { rand::thread_rng() .sample_iter(rand::distributions::Alphanumeric) - .take(30) + .take(len) .map(char::from) .collect() } +pub fn random_password() -> String { + random_hex(30) +} + pub mod password { const HAS_NUM: u8 = 1; const HAS_UPPER: u8 = 1 << 1; diff --git a/crates/squadron-api/src/http/api/authentication/change_password.rs b/crates/squadron-api/src/http/api/authentication/change_password.rs index afde3a9..67dce06 100644 --- a/crates/squadron-api/src/http/api/authentication/change_password.rs +++ b/crates/squadron-api/src/http/api/authentication/change_password.rs @@ -1,4 +1,3 @@ -use actix_jwt_session::Authenticated; use actix_web::web::{Data, Json}; use actix_web::{post, HttpResponse}; use sea_orm::{DatabaseConnection, DatabaseTransaction, EntityTrait, Set}; @@ -6,9 +5,8 @@ use serde_json::json; use tracing::warn; use super::password::*; -use crate::extractors::RequireInstanceConfigured; +use crate::extractors::{RequireUser, *}; use crate::models::{Error, JsonError, JsonErrorDetails}; -use crate::session::AppClaims; use crate::utils::SetPassword; use crate::{db_commit, db_rollback, db_t, utils}; @@ -23,13 +21,13 @@ struct Input { #[post("/users/me/change-password")] pub async fn change_password( _: RequireInstanceConfigured, + user: RequireUser, input: Json, - auth: Authenticated, db: Data, ) -> Result> { let mut t = db_t!(db)?; - match try_change_password(input, auth, &mut t).await { + match try_change_password(input, user, &mut t).await { Ok(r) => { db_commit!(t)?; Ok(r) @@ -44,18 +42,9 @@ pub async fn change_password( async fn try_change_password( input: Json, - auth: Authenticated, + user: RequireUser, t: &mut DatabaseTransaction, ) -> Result> { - let user = entities::prelude::Users::find_by_id(auth.account_id()) - .one(&mut *t) - .await - .map_err(|e| { - tracing::error!("Failed to find user while change password: {e}"); - Error::DatabaseError - })? - .ok_or(Error::UserRequired)?; - let input = input.into_inner(); if input.new_password != input.confirm_password { return Err(JsonError::new( @@ -109,6 +98,7 @@ mod tests { use tracing_test::traced_test; use uuid::Uuid; + use super::super::*; use super::*; use crate::session; @@ -163,7 +153,16 @@ mod tests { } ActiveModel { instance_name: Set("Plan Free".into()), + is_telemetry_enabled: Set(true), + is_support_required: Set(true), is_setup_done: Set(true), + is_signup_screen_visited: Set(true), + is_verified: Set(true), + user_count: Set(0), + instance_id: Set(random_hex(12)), + api_key: Set(random_hex(8)), + version: Set(env!("CARGO_PKG_VERSION").to_string()), + last_checked_at: Set(chrono::Utc::now().fixed_offset()), ..Default::default() } .save(&**db) @@ -176,7 +175,6 @@ mod tests { user_name: &str, pass: &str, ) -> entities::users::Model { - use entities::prelude::Users; use entities::users::*; use sea_orm::*; @@ -264,7 +262,7 @@ mod tests { let resp = test::call_service(&app, req).await; - assert_eq!(resp.status(), StatusCode::BAD_REQUEST); + assert_eq!(resp.status(), StatusCode::UNAUTHORIZED); let body = resp.into_body(); let bytes = String::from_utf8(to_bytes(body).await.unwrap()[..].to_vec()).unwrap(); diff --git a/crates/squadron-api/src/http/api/authentication/forgot_password.rs b/crates/squadron-api/src/http/api/authentication/forgot_password.rs index 4026be6..a88d0a4 100644 --- a/crates/squadron-api/src/http/api/authentication/forgot_password.rs +++ b/crates/squadron-api/src/http/api/authentication/forgot_password.rs @@ -60,6 +60,7 @@ async fn try_forgot_password( .await .map_err(|e| { error!("Failed to load user for forgot-password: {e}"); + eprintln!("Failed to load user for forgot-password: {e}"); Error::DatabaseError })? .ok_or_else(|| JsonError::new("Please check the email"))?; @@ -87,6 +88,7 @@ async fn try_forgot_password( .await { error!("Failed to send forgot pass email event: {e}"); + eprintln!("Failed to send forgot pass email event: {e}"); Err( JsonError::new("Something went wrong. Please contact administrator.") .with_status(StatusCode::INTERNAL_SERVER_ERROR), @@ -112,6 +114,7 @@ mod tests { use sea_orm::Database; use serde_json::json; use squadron_contract::deadpool_redis; + use squadron_contract::event_bus::Client as EventBusClient; use tracing_test::traced_test; use uuid::Uuid; @@ -152,6 +155,8 @@ mod tests { .app_data(Data::new($session_storage.clone())) .app_data($db.clone()) .app_data(Data::new(redis)) + .app_data(Data::new(EventBusClient::new_succ_mock())) + .app_data(Data::new(PasswordResetSecret::new("ahsdhy9asd".to_string()))) .wrap(actix_web::middleware::NormalizePath::trim()) .wrap(actix_web::middleware::Logger::default()) .wrap(factory) @@ -171,7 +176,16 @@ mod tests { } ActiveModel { instance_name: Set("Plan Free".into()), + is_telemetry_enabled: Set(true), + is_support_required: Set(true), is_setup_done: Set(true), + is_signup_screen_visited: Set(true), + is_verified: Set(true), + user_count: Set(0), + instance_id: Set(random_hex(12)), + api_key: Set(random_hex(8)), + version: Set(env!("CARGO_PKG_VERSION").to_string()), + last_checked_at: Set(chrono::Utc::now().fixed_offset()), ..Default::default() } .save(&**db) @@ -233,7 +247,7 @@ mod tests { .set_json(Input { email: "a89hsd9hasd@dsa9hs8.com".to_string(), }) - .uri("/forgot-password") + .uri("http://my-sq.mock/forgot-password") .method(Method::POST) .to_request(); @@ -258,7 +272,7 @@ mod tests { .set_json(Input { email: format!("no_user_forgot::??_pass@example.11"), }) - .uri("/forgot-password") + .uri("http://my-sq.mock/forgot-password") .method(Method::POST) .to_request(); @@ -283,13 +297,13 @@ mod tests { .set_json(Input { email: user.email.unwrap(), }) - .uri("/forgot-password") + .uri("http://my-sq.mock/forgot-password") .method(Method::POST) .to_request(); let resp = test::call_service(&app, req).await; - assert_eq!(resp.status(), StatusCode::BAD_REQUEST); + assert_eq!(resp.status(), StatusCode::OK); let body = resp.into_body(); let json: serde_json::Value = diff --git a/crates/squadron-api/src/http/api/authentication/reset_password.rs b/crates/squadron-api/src/http/api/authentication/reset_password.rs index ffdd824..0c6a370 100644 --- a/crates/squadron-api/src/http/api/authentication/reset_password.rs +++ b/crates/squadron-api/src/http/api/authentication/reset_password.rs @@ -7,8 +7,8 @@ use reqwest::StatusCode; use sea_orm::{DatabaseConnection, DatabaseTransaction, EntityTrait, Set}; use serde::Deserialize; -use super::auth_http_response; use super::password::PassValidity; +use super::{auth_http_response, random_hex}; use crate::extractors::RequireInstanceConfigured; use crate::models::{ Error, JsonError, JsonErrorDetails, PasswordResetSecret, PasswordResetTimeout, @@ -188,7 +188,16 @@ mod tests { } ActiveModel { instance_name: Set("Plan Free".into()), + is_telemetry_enabled: Set(true), + is_support_required: Set(true), is_setup_done: Set(true), + is_signup_screen_visited: Set(true), + is_verified: Set(true), + user_count: Set(0), + instance_id: Set(random_hex(12)), + api_key: Set(random_hex(8)), + version: Set(env!("CARGO_PKG_VERSION").to_string()), + last_checked_at: Set(chrono::Utc::now().fixed_offset()), ..Default::default() } .save(&**db) diff --git a/crates/squadron-contract/Cargo.toml b/crates/squadron-contract/Cargo.toml index 83bca5f..f4bd380 100644 --- a/crates/squadron-contract/Cargo.toml +++ b/crates/squadron-contract/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +async-trait = "0.1.77" bincode = "1.3.3" chrono = { version = "0.4.31", default-features = false, features = ["serde", "std", "libc", "pure-rust-locales", "clock"] } deadpool-redis = { version = "0.14.0", features = ["serde"] } diff --git a/crates/squadron-contract/src/event_bus/mod.rs b/crates/squadron-contract/src/event_bus/mod.rs index 09e2b51..ccdd2f0 100644 --- a/crates/squadron-contract/src/event_bus/mod.rs +++ b/crates/squadron-contract/src/event_bus/mod.rs @@ -14,9 +14,65 @@ pub enum EventBusError { Serialize(#[from] bincode::Error), } +#[async_trait::async_trait] +pub trait NativeClient { + async fn publish( + &self, + topic: messages::Topic, + msg: messages::Msg, + qos: QoS, + retain: bool, + ) -> Result<(), EventBusError>; +} + +#[async_trait::async_trait] +impl NativeClient for rumqttc::AsyncClient { + async fn publish( + &self, + topic: messages::Topic, + msg: messages::Msg, + qos: QoS, + retain: bool, + ) -> Result<(), EventBusError> { + self.publish(topic.as_str(), qos, retain, msg.try_as_bytes()?) + .await?; + Ok(()) + } +} + +pub struct SuccMockClient; + +#[async_trait::async_trait] +impl NativeClient for SuccMockClient { + async fn publish( + &self, + _topic: messages::Topic, + _msg: messages::Msg, + _qos: QoS, + _retain: bool, + ) -> Result<(), EventBusError> { + Ok(()) + } +} + +pub struct FailMockClient; + +#[async_trait::async_trait] +impl NativeClient for FailMockClient { + async fn publish( + &self, + _topic: messages::Topic, + _msg: messages::Msg, + _qos: QoS, + _retain: bool, + ) -> Result<(), EventBusError> { + Err(EventBusError::NativeClient) + } +} + #[derive(Clone)] pub struct Client { - client: Arc>, + client: Arc>, } impl Client { @@ -26,6 +82,18 @@ impl Client { } } + pub fn new_succ_mock() -> Self { + Self { + client: Arc::new(Mutex::new(SuccMockClient)), + } + } + + pub fn new_fail_mock() -> Self { + Self { + client: Arc::new(Mutex::new(FailMockClient)), + } + } + pub async fn publish( &self, topic: messages::Topic, @@ -36,9 +104,7 @@ impl Client { let Ok(client) = self.client.lock() else { return Err(EventBusError::NativeClient); }; - client - .publish(topic.as_str(), qos, retain, msg.try_as_bytes()?) - .await?; + client.publish(topic, msg, qos, retain).await?; Ok(()) } } diff --git a/plane_db.sql b/plane_db.sql index 041c3f7..e1e092c 100644 --- a/plane_db.sql +++ b/plane_db.sql @@ -96,8 +96,8 @@ CREATE TABLE users ( -- CREATE TABLE workspaces ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(80) NOT NULL, logo character varying(200), @@ -113,8 +113,8 @@ CREATE TABLE workspaces ( -- CREATE TABLE projects ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -147,8 +147,8 @@ CREATE TABLE projects ( -- CREATE TABLE modules ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -173,8 +173,8 @@ CREATE TABLE modules ( -- CREATE TABLE pages ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description jsonb NOT NULL, @@ -198,8 +198,8 @@ CREATE TABLE pages ( -- CREATE TABLE states ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -221,8 +221,8 @@ CREATE TABLE states ( -- CREATE TABLE issues ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description jsonb NOT NULL, @@ -252,8 +252,8 @@ CREATE TABLE issues ( -- CREATE TABLE issue_comments ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), comment_stripped text NOT NULL, attachments character varying(200)[] NOT NULL, @@ -276,8 +276,8 @@ CREATE TABLE issue_comments ( -- CREATE TABLE cycles ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -299,8 +299,8 @@ CREATE TABLE cycles ( -- CREATE TABLE estimates ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -315,8 +315,8 @@ CREATE TABLE estimates ( -- CREATE TABLE analytic_views ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -331,8 +331,8 @@ CREATE TABLE analytic_views ( -- CREATE TABLE api_activity_logs ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), token_identifier character varying(255) NOT NULL, path character varying(255) NOT NULL, @@ -350,8 +350,8 @@ CREATE TABLE api_activity_logs ( ); CREATE TABLE api_tokens ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), token character varying(255) NOT NULL, label character varying(255) NOT NULL, @@ -449,8 +449,8 @@ CREATE TABLE authtoken_token ( -- CREATE TABLE comment_reactions ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), reaction character varying(20) NOT NULL, actor_id uuid NOT NULL, @@ -466,8 +466,8 @@ CREATE TABLE comment_reactions ( -- CREATE TABLE cycle_favorites ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, cycle_id uuid NOT NULL REFERENCES cycles (id), @@ -482,8 +482,8 @@ CREATE TABLE cycle_favorites ( -- CREATE TABLE cycle_issues ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, cycle_id uuid NOT NULL REFERENCES cycles (id), @@ -678,8 +678,8 @@ CREATE TABLE django_session ( -- CREATE TABLE estimate_points ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), key integer NOT NULL, description text NOT NULL, @@ -696,8 +696,8 @@ CREATE TABLE estimate_points ( -- CREATE TABLE exporters ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), project uuid[], provider character varying(50) NOT NULL, @@ -717,8 +717,8 @@ CREATE TABLE exporters ( -- CREATE TABLE file_assets ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), attributes jsonb NOT NULL, asset character varying(100) NOT NULL, @@ -733,8 +733,8 @@ CREATE TABLE file_assets ( -- CREATE TABLE github_comment_syncs ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), repo_comment_id bigint NOT NULL, comment_id uuid NOT NULL, @@ -750,8 +750,8 @@ CREATE TABLE github_comment_syncs ( -- CREATE TABLE github_issue_syncs ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), repo_issue_id bigint NOT NULL, github_issue_id bigint NOT NULL, @@ -769,8 +769,8 @@ CREATE TABLE github_issue_syncs ( -- CREATE TABLE github_repositories ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(500) NOT NULL, url character varying(200), @@ -788,8 +788,8 @@ CREATE TABLE github_repositories ( -- CREATE TABLE github_repository_syncs ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), credentials jsonb NOT NULL, actor_id uuid NOT NULL, @@ -807,8 +807,8 @@ CREATE TABLE github_repository_syncs ( -- CREATE TABLE global_views ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -827,8 +827,8 @@ CREATE TABLE global_views ( -- CREATE TABLE importers ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), service character varying(50) NOT NULL, status character varying(50) NOT NULL, @@ -849,8 +849,8 @@ CREATE TABLE importers ( -- CREATE TABLE inbox_issues ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), status integer NOT NULL, snoozed_till timestamp with time zone, @@ -871,8 +871,8 @@ CREATE TABLE inbox_issues ( -- CREATE TABLE inboxes ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -889,8 +889,8 @@ CREATE TABLE inboxes ( -- CREATE TABLE instance_admins ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), role roles NOT NULL, is_verified boolean NOT NULL, @@ -905,8 +905,8 @@ CREATE TABLE instance_admins ( -- CREATE TABLE instance_configurations ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), key character varying(100) NOT NULL, value text, @@ -921,8 +921,8 @@ CREATE TABLE instance_configurations ( -- CREATE TABLE instances ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at timestamp with time zone NOT NULL DEFAULT NOW(), + updated_at timestamp with time zone NOT NULL DEFAULT NOW(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), instance_name character varying(255) NOT NULL, whitelist_emails text, @@ -948,8 +948,8 @@ CREATE TABLE instances ( -- CREATE TABLE integrations ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at timestamp with time zone NOT NULL DEFAULT NOW(), + updated_at timestamp with time zone NOT NULL DEFAULT NOW(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), title character varying(400) NOT NULL, provider character varying(400) NOT NULL, @@ -972,8 +972,8 @@ CREATE TABLE integrations ( -- CREATE TABLE issue_activities ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), verb character varying(255) NOT NULL, field character varying(255), @@ -998,8 +998,8 @@ CREATE TABLE issue_activities ( -- CREATE TABLE issue_assignees ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), assignee_id uuid NOT NULL, created_by_id uuid, @@ -1014,8 +1014,8 @@ CREATE TABLE issue_assignees ( -- CREATE TABLE issue_attachments ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), attributes jsonb NOT NULL, asset character varying(100) NOT NULL, @@ -1031,8 +1031,8 @@ CREATE TABLE issue_attachments ( -- CREATE TABLE issue_blockers ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), block_id uuid NOT NULL, blocked_by_id uuid NOT NULL, @@ -1047,8 +1047,8 @@ CREATE TABLE issue_blockers ( -- CREATE TABLE issue_labels ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, issue_id uuid NOT NULL REFERENCES issues (id), @@ -1063,8 +1063,8 @@ CREATE TABLE issue_labels ( -- CREATE TABLE issue_links ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), title character varying(255), url character varying(200) NOT NULL, @@ -1081,8 +1081,8 @@ CREATE TABLE issue_links ( -- CREATE TABLE issue_mentions ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, issue_id uuid NOT NULL REFERENCES issues (id), @@ -1097,8 +1097,8 @@ CREATE TABLE issue_mentions ( -- CREATE TABLE issue_properties ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), properties jsonb NOT NULL, created_by_id uuid, @@ -1113,8 +1113,8 @@ CREATE TABLE issue_properties ( -- CREATE TABLE issue_reactions ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), reaction character varying(20) NOT NULL, actor_id uuid NOT NULL, @@ -1130,8 +1130,8 @@ CREATE TABLE issue_reactions ( -- CREATE TABLE issue_relations ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), relation_type character varying(20) NOT NULL, created_by_id uuid, @@ -1147,8 +1147,8 @@ CREATE TABLE issue_relations ( -- CREATE TABLE issue_sequences ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), sequence bigint NOT NULL, deleted boolean NOT NULL, @@ -1165,8 +1165,8 @@ CREATE TABLE issue_sequences ( -- CREATE TABLE issue_subscribers ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, issue_id uuid NOT NULL REFERENCES issues (id), @@ -1181,8 +1181,8 @@ CREATE TABLE issue_subscribers ( -- CREATE TABLE issue_views ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -1201,8 +1201,8 @@ CREATE TABLE issue_views ( -- CREATE TABLE issue_votes ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), vote integer NOT NULL, actor_id uuid NOT NULL, @@ -1218,8 +1218,8 @@ CREATE TABLE issue_votes ( -- CREATE TABLE labels ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -1239,8 +1239,8 @@ CREATE TABLE labels ( -- CREATE TABLE module_favorites ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, module_id uuid NOT NULL REFERENCES modules (id), @@ -1255,8 +1255,8 @@ CREATE TABLE module_favorites ( -- CREATE TABLE module_issues ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, issue_id uuid NOT NULL REFERENCES issues (id), @@ -1271,8 +1271,8 @@ CREATE TABLE module_issues ( -- CREATE TABLE module_links ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), title character varying(255), url character varying(200) NOT NULL, @@ -1289,8 +1289,8 @@ CREATE TABLE module_links ( -- CREATE TABLE module_members ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, member_id uuid NOT NULL, @@ -1305,8 +1305,8 @@ CREATE TABLE module_members ( -- CREATE TABLE notifications ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), data jsonb, entity_identifier uuid, @@ -1332,8 +1332,8 @@ CREATE TABLE notifications ( -- CREATE TABLE page_blocks ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description jsonb NOT NULL, @@ -1355,8 +1355,8 @@ CREATE TABLE page_blocks ( -- CREATE TABLE page_favorites ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, page_id uuid NOT NULL REFERENCES pages (id), @@ -1371,8 +1371,8 @@ CREATE TABLE page_favorites ( -- CREATE TABLE page_labels ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, label_id uuid NOT NULL, @@ -1387,8 +1387,8 @@ CREATE TABLE page_labels ( -- CREATE TABLE page_logs ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), transaction uuid NOT NULL, entity_identifier uuid, @@ -1405,8 +1405,8 @@ CREATE TABLE page_logs ( -- CREATE TABLE project_deploy_boards ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), anchor character varying(255) NOT NULL, comments boolean NOT NULL, @@ -1425,8 +1425,8 @@ CREATE TABLE project_deploy_boards ( -- CREATE TABLE project_favorites ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, project_id uuid NOT NULL REFERENCES projects (id), @@ -1441,8 +1441,8 @@ CREATE TABLE project_favorites ( CREATE TABLE project_identifiers ( id bigint NOT NULL PRIMARY KEY, - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), name character varying(12) NOT NULL, created_by_id uuid, project_id uuid NOT NULL REFERENCES projects (id), @@ -1467,8 +1467,8 @@ ALTER TABLE project_identifiers ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDEN -- CREATE TABLE project_member_invites ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), email character varying(255) NOT NULL, accepted boolean NOT NULL, @@ -1487,8 +1487,8 @@ CREATE TABLE project_member_invites ( -- CREATE TABLE project_members ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), comment text, role project_member_roles NOT NULL DEFAULT 'Member' :: project_member_roles, @@ -1509,8 +1509,8 @@ CREATE TABLE project_members ( -- CREATE TABLE project_public_members ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, member_id uuid NOT NULL, @@ -1524,8 +1524,8 @@ CREATE TABLE project_public_members ( -- CREATE TABLE slack_project_syncs ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), access_token character varying(300) NOT NULL, scopes text NOT NULL, @@ -1546,8 +1546,8 @@ CREATE TABLE slack_project_syncs ( -- CREATE TABLE social_login_connections ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), medium character varying(20) NOT NULL, last_login_at timestamp with time zone, @@ -1564,8 +1564,8 @@ CREATE TABLE social_login_connections ( -- CREATE TABLE team_members ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, member_id uuid NOT NULL, @@ -1579,8 +1579,8 @@ CREATE TABLE team_members ( -- CREATE TABLE teams ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(255) NOT NULL, description text NOT NULL, @@ -1686,8 +1686,8 @@ ALTER TABLE users_user_permissions ALTER COLUMN id ADD GENERATED BY DEFAULT AS I -- CREATE TABLE view_favorites ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), created_by_id uuid, project_id uuid NOT NULL REFERENCES projects (id), @@ -1702,8 +1702,8 @@ CREATE TABLE view_favorites ( -- CREATE TABLE webhook_logs ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), event_type character varying(255), request_method character varying(10), @@ -1725,8 +1725,8 @@ CREATE TABLE webhook_logs ( -- CREATE TABLE webhooks ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), url character varying(200) NOT NULL, is_active boolean NOT NULL, @@ -1746,8 +1746,8 @@ CREATE TABLE webhooks ( -- CREATE TABLE workspace_integrations ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), metadata jsonb NOT NULL, config jsonb NOT NULL, @@ -1764,8 +1764,8 @@ CREATE TABLE workspace_integrations ( -- CREATE TABLE workspace_member_invites ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), email character varying(255) NOT NULL, accepted boolean NOT NULL, @@ -1783,8 +1783,8 @@ CREATE TABLE workspace_member_invites ( -- CREATE TABLE workspace_members ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), role roles NOT NULL DEFAULT 'Member' :: roles, created_by_id uuid, @@ -1803,8 +1803,8 @@ CREATE TABLE workspace_members ( -- CREATE TABLE workspace_themes ( - created_at timestamp with time zone NOT NULL, - updated_at timestamp with time zone NOT NULL, + created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), + updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), id uuid NOT NULL PRIMARY KEY DEFAULT uuid_generate_v4(), name character varying(300) NOT NULL, colors jsonb NOT NULL,