diff --git a/db/company.sql.go b/db/company.sql.go index a8d0bc3..a2936ff 100644 --- a/db/company.sql.go +++ b/db/company.sql.go @@ -7,8 +7,6 @@ package db import ( "context" - - "github.com/jackc/pgx/v5/pgtype" ) const createCompany = `-- name: CreateCompany :one @@ -33,9 +31,9 @@ RETURNING id, owner_user_id, name, description, is_verified, created_at, updated ` type CreateCompanyParams struct { - OwnerUserID pgtype.UUID + OwnerUserID string Name string - Description pgtype.Text + Description *string } func (q *Queries) CreateCompany(ctx context.Context, arg CreateCompanyParams) (Company, error) { @@ -60,7 +58,7 @@ WHERE id = $1 ` // TODO: Add + use auth to ensure only company owners can delete -func (q *Queries) DeleteCompany(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteCompany(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteCompany, id) return err } @@ -71,7 +69,7 @@ FROM companies WHERE id = $1 LIMIT 1 ` -func (q *Queries) GetCompanyByID(ctx context.Context, id pgtype.UUID) (Company, error) { +func (q *Queries) GetCompanyByID(ctx context.Context, id string) (Company, error) { row := q.db.QueryRow(ctx, getCompanyByID, id) var i Company err := row.Scan( diff --git a/db/company_documents.sql.go b/db/company_documents.sql.go index 36b107f..c3eb816 100644 --- a/db/company_documents.sql.go +++ b/db/company_documents.sql.go @@ -7,8 +7,6 @@ package db import ( "context" - - "github.com/jackc/pgx/v5/pgtype" ) const createCompanyDocument = `-- name: CreateCompanyDocument :one @@ -23,7 +21,7 @@ RETURNING id, company_id, document_type, file_url, created_at, updated_at ` type CreateCompanyDocumentParams struct { - CompanyID pgtype.UUID + CompanyID string DocumentType string FileUrl string } @@ -47,7 +45,7 @@ DELETE FROM company_documents WHERE id = $1 ` -func (q *Queries) DeleteCompanyDocument(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteCompanyDocument(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteCompanyDocument, id) return err } @@ -57,7 +55,7 @@ SELECT id, company_id, document_type, file_url, created_at, updated_at FROM comp WHERE id = $1 LIMIT 1 ` -func (q *Queries) GetCompanyDocumentByID(ctx context.Context, id pgtype.UUID) (CompanyDocument, error) { +func (q *Queries) GetCompanyDocumentByID(ctx context.Context, id string) (CompanyDocument, error) { row := q.db.QueryRow(ctx, getCompanyDocumentByID, id) var i CompanyDocument err := row.Scan( @@ -77,7 +75,7 @@ WHERE company_id = $1 ORDER BY created_at DESC ` -func (q *Queries) ListCompanyDocuments(ctx context.Context, companyID pgtype.UUID) ([]CompanyDocument, error) { +func (q *Queries) ListCompanyDocuments(ctx context.Context, companyID string) ([]CompanyDocument, error) { rows, err := q.db.Query(ctx, listCompanyDocuments, companyID) if err != nil { return nil, err @@ -111,7 +109,7 @@ ORDER BY created_at DESC ` type ListDocumentsByTypeParams struct { - CompanyID pgtype.UUID + CompanyID string DocumentType string } @@ -153,7 +151,7 @@ RETURNING id, company_id, document_type, file_url, created_at, updated_at ` type UpdateCompanyDocumentParams struct { - ID pgtype.UUID + ID string DocumentType string FileUrl string } diff --git a/db/company_financials.sql.go b/db/company_financials.sql.go index 0f48b22..c2d70d9 100644 --- a/db/company_financials.sql.go +++ b/db/company_financials.sql.go @@ -43,7 +43,7 @@ RETURNING id, company_id, financial_year, revenue, expenses, profit, sales, amou ` type CreateCompanyFinancialsParams struct { - CompanyID pgtype.UUID + CompanyID string FinancialYear int32 Revenue pgtype.Numeric Expenses pgtype.Numeric @@ -91,7 +91,7 @@ AND financial_year = $2 ` type DeleteCompanyFinancialsParams struct { - CompanyID pgtype.UUID + CompanyID string FinancialYear int32 } @@ -109,7 +109,7 @@ LIMIT 1 ` type GetCompanyFinancialsByYearParams struct { - CompanyID pgtype.UUID + CompanyID string FinancialYear int32 } @@ -141,7 +141,7 @@ ORDER BY financial_year DESC LIMIT 1 ` -func (q *Queries) GetLatestCompanyFinancials(ctx context.Context, companyID pgtype.UUID) (CompanyFinancial, error) { +func (q *Queries) GetLatestCompanyFinancials(ctx context.Context, companyID string) (CompanyFinancial, error) { row := q.db.QueryRow(ctx, getLatestCompanyFinancials, companyID) var i CompanyFinancial err := row.Scan( @@ -168,7 +168,7 @@ WHERE company_id = $1 ORDER BY financial_year DESC ` -func (q *Queries) ListCompanyFinancials(ctx context.Context, companyID pgtype.UUID) ([]CompanyFinancial, error) { +func (q *Queries) ListCompanyFinancials(ctx context.Context, companyID string) ([]CompanyFinancial, error) { rows, err := q.db.Query(ctx, listCompanyFinancials, companyID) if err != nil { return nil, err @@ -218,7 +218,7 @@ RETURNING id, company_id, financial_year, revenue, expenses, profit, sales, amou ` type UpdateCompanyFinancialsParams struct { - CompanyID pgtype.UUID + CompanyID string FinancialYear int32 Revenue pgtype.Numeric Expenses pgtype.Numeric diff --git a/db/company_questions_answers.sql.go b/db/company_questions_answers.sql.go index e219ab2..86ec273 100644 --- a/db/company_questions_answers.sql.go +++ b/db/company_questions_answers.sql.go @@ -23,8 +23,8 @@ RETURNING id, company_id, question_id, answer_text, created_at, updated_at, dele ` type CreateCompanyAnswerParams struct { - CompanyID pgtype.UUID - QuestionID pgtype.UUID + CompanyID string + QuestionID string AnswerText string } @@ -76,14 +76,14 @@ LIMIT 1 ` type GetCompanyAnswerParams struct { - CompanyID pgtype.UUID - QuestionID pgtype.UUID + CompanyID string + QuestionID string } type GetCompanyAnswerRow struct { - ID pgtype.UUID - CompanyID pgtype.UUID - QuestionID pgtype.UUID + ID string + CompanyID string + QuestionID string AnswerText string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp @@ -113,7 +113,7 @@ WHERE id = $1 AND deleted_at IS NULL LIMIT 1 ` -func (q *Queries) GetQuestion(ctx context.Context, id pgtype.UUID) (Question, error) { +func (q *Queries) GetQuestion(ctx context.Context, id string) (Question, error) { row := q.db.QueryRow(ctx, getQuestion, id) var i Question err := row.Scan( @@ -137,9 +137,9 @@ ORDER BY cqa.created_at DESC ` type ListCompanyAnswersRow struct { - ID pgtype.UUID - CompanyID pgtype.UUID - QuestionID pgtype.UUID + ID string + CompanyID string + QuestionID string AnswerText string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp @@ -147,7 +147,7 @@ type ListCompanyAnswersRow struct { QuestionText string } -func (q *Queries) ListCompanyAnswers(ctx context.Context, companyID pgtype.UUID) ([]ListCompanyAnswersRow, error) { +func (q *Queries) ListCompanyAnswers(ctx context.Context, companyID string) ([]ListCompanyAnswersRow, error) { rows, err := q.db.Query(ctx, listCompanyAnswers, companyID) if err != nil { return nil, err @@ -215,8 +215,8 @@ WHERE company_id = $1 AND question_id = $2 ` type SoftDeleteCompanyAnswerParams struct { - CompanyID pgtype.UUID - QuestionID pgtype.UUID + CompanyID string + QuestionID string } func (q *Queries) SoftDeleteCompanyAnswer(ctx context.Context, arg SoftDeleteCompanyAnswerParams) error { @@ -230,7 +230,7 @@ SET deleted_at = NOW() WHERE id = $1 ` -func (q *Queries) SoftDeleteQuestion(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) SoftDeleteQuestion(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, softDeleteQuestion, id) return err } @@ -245,8 +245,8 @@ RETURNING id, company_id, question_id, answer_text, created_at, updated_at, dele ` type UpdateCompanyAnswerParams struct { - CompanyID pgtype.UUID - QuestionID pgtype.UUID + CompanyID string + QuestionID string AnswerText string } diff --git a/db/employee.sql.go b/db/employee.sql.go index f9400f8..911298e 100644 --- a/db/employee.sql.go +++ b/db/employee.sql.go @@ -7,8 +7,6 @@ package db import ( "context" - - "github.com/jackc/pgx/v5/pgtype" ) const createEmployee = `-- name: CreateEmployee :one @@ -25,11 +23,11 @@ RETURNING id, company_id, name, email, role, bio, created_at, updated_at ` type CreateEmployeeParams struct { - CompanyID pgtype.UUID + CompanyID string Name string Email string Role string - Bio pgtype.Text + Bio *string } func (q *Queries) CreateEmployee(ctx context.Context, arg CreateEmployeeParams) (Employee, error) { @@ -59,7 +57,7 @@ DELETE FROM employees WHERE id = $1 ` -func (q *Queries) DeleteEmployee(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteEmployee(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteEmployee, id) return err } @@ -90,7 +88,7 @@ SELECT id, company_id, name, email, role, bio, created_at, updated_at FROM emplo WHERE id = $1 LIMIT 1 ` -func (q *Queries) GetEmployeeByID(ctx context.Context, id pgtype.UUID) (Employee, error) { +func (q *Queries) GetEmployeeByID(ctx context.Context, id string) (Employee, error) { row := q.db.QueryRow(ctx, getEmployeeByID, id) var i Employee err := row.Scan( @@ -146,7 +144,7 @@ WHERE company_id = $1 ORDER BY created_at DESC ` -func (q *Queries) ListEmployeesByCompany(ctx context.Context, companyID pgtype.UUID) ([]Employee, error) { +func (q *Queries) ListEmployeesByCompany(ctx context.Context, companyID string) ([]Employee, error) { rows, err := q.db.Query(ctx, listEmployeesByCompany, companyID) if err != nil { return nil, err @@ -187,10 +185,10 @@ RETURNING id, company_id, name, email, role, bio, created_at, updated_at ` type UpdateEmployeeParams struct { - ID pgtype.UUID + ID string Name string Role string - Bio pgtype.Text + Bio *string } func (q *Queries) UpdateEmployee(ctx context.Context, arg UpdateEmployeeParams) (Employee, error) { diff --git a/db/funding_transactions.sql.go b/db/funding_transactions.sql.go index e78b3cf..b1723d5 100644 --- a/db/funding_transactions.sql.go +++ b/db/funding_transactions.sql.go @@ -27,7 +27,7 @@ RETURNING id, project_id, amount, currency, transaction_hash, from_wallet_addres ` type CreateFundingTransactionParams struct { - ProjectID pgtype.UUID + ProjectID string Amount pgtype.Numeric Currency string TransactionHash string @@ -67,7 +67,7 @@ DELETE FROM funding_transactions WHERE id = $1 ` -func (q *Queries) DeleteFundingTransaction(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteFundingTransaction(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteFundingTransaction, id) return err } @@ -77,7 +77,7 @@ SELECT id, project_id, amount, currency, transaction_hash, from_wallet_address, WHERE id = $1 LIMIT 1 ` -func (q *Queries) GetFundingTransaction(ctx context.Context, id pgtype.UUID) (FundingTransaction, error) { +func (q *Queries) GetFundingTransaction(ctx context.Context, id string) (FundingTransaction, error) { row := q.db.QueryRow(ctx, getFundingTransaction, id) var i FundingTransaction err := row.Scan( @@ -137,7 +137,7 @@ WHERE project_id = $1 ORDER BY created_at DESC ` -func (q *Queries) ListProjectFundingTransactions(ctx context.Context, projectID pgtype.UUID) ([]FundingTransaction, error) { +func (q *Queries) ListProjectFundingTransactions(ctx context.Context, projectID string) ([]FundingTransaction, error) { rows, err := q.db.Query(ctx, listProjectFundingTransactions, projectID) if err != nil { return nil, err @@ -178,7 +178,7 @@ RETURNING id, project_id, amount, currency, transaction_hash, from_wallet_addres ` type UpdateFundingTransactionStatusParams struct { - ID pgtype.UUID + ID string Status string } diff --git a/db/meetings.sql.go b/db/meetings.sql.go index d45eea1..0e72a96 100644 --- a/db/meetings.sql.go +++ b/db/meetings.sql.go @@ -7,8 +7,7 @@ package db import ( "context" - - "github.com/jackc/pgx/v5/pgtype" + "time" ) const createMeeting = `-- name: CreateMeeting :one @@ -27,13 +26,13 @@ RETURNING id, project_id, scheduled_by_user_id, start_time, end_time, meeting_ur ` type CreateMeetingParams struct { - ProjectID pgtype.UUID - ScheduledByUserID pgtype.UUID - StartTime pgtype.Timestamp - EndTime pgtype.Timestamp - MeetingUrl pgtype.Text - Location pgtype.Text - Notes pgtype.Text + ProjectID string + ScheduledByUserID string + StartTime time.Time + EndTime time.Time + MeetingUrl *string + Location *string + Notes *string } func (q *Queries) CreateMeeting(ctx context.Context, arg CreateMeetingParams) (Meeting, error) { @@ -67,7 +66,7 @@ DELETE FROM meetings WHERE id = $1 ` -func (q *Queries) DeleteMeeting(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteMeeting(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteMeeting, id) return err } @@ -77,7 +76,7 @@ SELECT id, project_id, scheduled_by_user_id, start_time, end_time, meeting_url, WHERE id = $1 LIMIT 1 ` -func (q *Queries) GetMeeting(ctx context.Context, id pgtype.UUID) (Meeting, error) { +func (q *Queries) GetMeeting(ctx context.Context, id string) (Meeting, error) { row := q.db.QueryRow(ctx, getMeeting, id) var i Meeting err := row.Scan( @@ -137,7 +136,7 @@ WHERE project_id = $1 ORDER BY start_time DESC ` -func (q *Queries) ListProjectMeetings(ctx context.Context, projectID pgtype.UUID) ([]Meeting, error) { +func (q *Queries) ListProjectMeetings(ctx context.Context, projectID string) ([]Meeting, error) { rows, err := q.db.Query(ctx, listProjectMeetings, projectID) if err != nil { return nil, err @@ -182,12 +181,12 @@ RETURNING id, project_id, scheduled_by_user_id, start_time, end_time, meeting_ur ` type UpdateMeetingParams struct { - ID pgtype.UUID - StartTime pgtype.Timestamp - EndTime pgtype.Timestamp - MeetingUrl pgtype.Text - Location pgtype.Text - Notes pgtype.Text + ID string + StartTime time.Time + EndTime time.Time + MeetingUrl *string + Location *string + Notes *string } func (q *Queries) UpdateMeeting(ctx context.Context, arg UpdateMeetingParams) (Meeting, error) { diff --git a/db/models.go b/db/models.go index e22402e..2d1cd0f 100644 --- a/db/models.go +++ b/db/models.go @@ -5,23 +5,25 @@ package db import ( + "time" + "github.com/jackc/pgx/v5/pgtype" ) type Company struct { - ID pgtype.UUID - OwnerUserID pgtype.UUID + ID string + OwnerUserID string Name string - Description pgtype.Text + Description *string IsVerified bool - CreatedAt pgtype.Timestamp - UpdatedAt pgtype.Timestamp + CreatedAt time.Time + UpdatedAt time.Time DeletedAt pgtype.Timestamp } type CompanyDocument struct { - ID pgtype.UUID - CompanyID pgtype.UUID + ID string + CompanyID string DocumentType string FileUrl string CreatedAt pgtype.Timestamp @@ -29,8 +31,8 @@ type CompanyDocument struct { } type CompanyFinancial struct { - ID pgtype.UUID - CompanyID pgtype.UUID + ID string + CompanyID string FinancialYear int32 Revenue pgtype.Numeric Expenses pgtype.Numeric @@ -44,9 +46,9 @@ type CompanyFinancial struct { } type CompanyQuestionAnswer struct { - ID pgtype.UUID - CompanyID pgtype.UUID - QuestionID pgtype.UUID + ID string + CompanyID string + QuestionID string AnswerText string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp @@ -54,19 +56,19 @@ type CompanyQuestionAnswer struct { } type Employee struct { - ID pgtype.UUID - CompanyID pgtype.UUID + ID string + CompanyID string Name string Email string Role string - Bio pgtype.Text + Bio *string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp } type FundingTransaction struct { - ID pgtype.UUID - ProjectID pgtype.UUID + ID string + ProjectID string Amount pgtype.Numeric Currency string TransactionHash string @@ -78,40 +80,40 @@ type FundingTransaction struct { } type Meeting struct { - ID pgtype.UUID - ProjectID pgtype.UUID - ScheduledByUserID pgtype.UUID - StartTime pgtype.Timestamp - EndTime pgtype.Timestamp - MeetingUrl pgtype.Text - Location pgtype.Text - Notes pgtype.Text + ID string + ProjectID string + ScheduledByUserID string + StartTime time.Time + EndTime time.Time + MeetingUrl *string + Location *string + Notes *string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp } type Project struct { - ID pgtype.UUID - CompanyID pgtype.UUID + ID string + CompanyID string Title string - Description pgtype.Text + Description *string Status string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp } type ProjectComment struct { - ID pgtype.UUID - ProjectID pgtype.UUID - UserID pgtype.UUID + ID string + ProjectID string + UserID string Comment string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp } type ProjectFile struct { - ID pgtype.UUID - ProjectID pgtype.UUID + ID string + ProjectID string FileType string FileUrl string CreatedAt pgtype.Timestamp @@ -119,8 +121,8 @@ type ProjectFile struct { } type ProjectLink struct { - ID pgtype.UUID - ProjectID pgtype.UUID + ID string + ProjectID string LinkType string Url string CreatedAt pgtype.Timestamp @@ -128,14 +130,14 @@ type ProjectLink struct { } type ProjectTag struct { - ID pgtype.UUID - ProjectID pgtype.UUID - TagID pgtype.UUID + ID string + ProjectID string + TagID string CreatedAt pgtype.Timestamp } type Question struct { - ID pgtype.UUID + ID string QuestionText string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp @@ -143,30 +145,30 @@ type Question struct { } type ResourceRequest struct { - ID pgtype.UUID - CompanyID pgtype.UUID + ID string + CompanyID string ResourceType string - Description pgtype.Text + Description *string Status string - CreatedAt pgtype.Timestamp - UpdatedAt pgtype.Timestamp + CreatedAt time.Time + UpdatedAt time.Time } type Tag struct { - ID pgtype.UUID + ID string Name string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp } type User struct { - ID pgtype.UUID + ID string Email string PasswordHash string - FirstName pgtype.Text - LastName pgtype.Text + FirstName *string + LastName *string Role string - WalletAddress pgtype.Text + WalletAddress *string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp } diff --git a/db/projects.sql.go b/db/projects.sql.go index 081f31d..cc01aa3 100644 --- a/db/projects.sql.go +++ b/db/projects.sql.go @@ -22,8 +22,8 @@ RETURNING id, project_id, tag_id, created_at ` type AddProjectTagParams struct { - ProjectID pgtype.UUID - TagID pgtype.UUID + ProjectID string + TagID string } func (q *Queries) AddProjectTag(ctx context.Context, arg AddProjectTagParams) (ProjectTag, error) { @@ -51,9 +51,9 @@ RETURNING id, company_id, title, description, status, created_at, updated_at ` type CreateProjectParams struct { - CompanyID pgtype.UUID + CompanyID string Title string - Description pgtype.Text + Description *string Status string } @@ -89,8 +89,8 @@ RETURNING id, project_id, user_id, comment, created_at, updated_at ` type CreateProjectCommentParams struct { - ProjectID pgtype.UUID - UserID pgtype.UUID + ProjectID string + UserID string Comment string } @@ -120,7 +120,7 @@ RETURNING id, project_id, file_type, file_url, created_at, updated_at ` type CreateProjectFileParams struct { - ProjectID pgtype.UUID + ProjectID string FileType string FileUrl string } @@ -151,7 +151,7 @@ RETURNING id, project_id, link_type, url, created_at, updated_at ` type CreateProjectLinkParams struct { - ProjectID pgtype.UUID + ProjectID string LinkType string Url string } @@ -175,7 +175,7 @@ DELETE FROM project_tags WHERE project_id = $1 ` -func (q *Queries) DeleteAllProjectTags(ctx context.Context, projectID pgtype.UUID) error { +func (q *Queries) DeleteAllProjectTags(ctx context.Context, projectID string) error { _, err := q.db.Exec(ctx, deleteAllProjectTags, projectID) return err } @@ -185,7 +185,7 @@ DELETE FROM projects WHERE id = $1 ` -func (q *Queries) DeleteProject(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteProject(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteProject, id) return err } @@ -195,7 +195,7 @@ DELETE FROM project_comments WHERE id = $1 ` -func (q *Queries) DeleteProjectComment(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteProjectComment(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteProjectComment, id) return err } @@ -205,7 +205,7 @@ DELETE FROM project_files WHERE id = $1 ` -func (q *Queries) DeleteProjectFile(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteProjectFile(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteProjectFile, id) return err } @@ -215,7 +215,7 @@ DELETE FROM project_links WHERE id = $1 ` -func (q *Queries) DeleteProjectLink(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteProjectLink(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteProjectLink, id) return err } @@ -226,8 +226,8 @@ WHERE project_id = $1 AND tag_id = $2 ` type DeleteProjectTagParams struct { - ProjectID pgtype.UUID - TagID pgtype.UUID + ProjectID string + TagID string } func (q *Queries) DeleteProjectTag(ctx context.Context, arg DeleteProjectTagParams) error { @@ -240,7 +240,7 @@ SELECT id, company_id, title, description, status, created_at, updated_at FROM p WHERE id = $1 LIMIT 1 ` -func (q *Queries) GetProject(ctx context.Context, id pgtype.UUID) (Project, error) { +func (q *Queries) GetProject(ctx context.Context, id string) (Project, error) { row := q.db.QueryRow(ctx, getProject, id) var i Project err := row.Scan( @@ -268,18 +268,18 @@ ORDER BY pc.created_at DESC ` type GetProjectCommentsRow struct { - ID pgtype.UUID - ProjectID pgtype.UUID - UserID pgtype.UUID + ID string + ProjectID string + UserID string Comment string CreatedAt pgtype.Timestamp UpdatedAt pgtype.Timestamp - FirstName pgtype.Text - LastName pgtype.Text + FirstName *string + LastName *string Email string } -func (q *Queries) GetProjectComments(ctx context.Context, projectID pgtype.UUID) ([]GetProjectCommentsRow, error) { +func (q *Queries) GetProjectComments(ctx context.Context, projectID string) ([]GetProjectCommentsRow, error) { rows, err := q.db.Query(ctx, getProjectComments, projectID) if err != nil { return nil, err @@ -315,7 +315,7 @@ WHERE project_id = $1 ORDER BY created_at DESC ` -func (q *Queries) ListProjectFiles(ctx context.Context, projectID pgtype.UUID) ([]ProjectFile, error) { +func (q *Queries) ListProjectFiles(ctx context.Context, projectID string) ([]ProjectFile, error) { rows, err := q.db.Query(ctx, listProjectFiles, projectID) if err != nil { return nil, err @@ -348,7 +348,7 @@ WHERE project_id = $1 ORDER BY created_at DESC ` -func (q *Queries) ListProjectLinks(ctx context.Context, projectID pgtype.UUID) ([]ProjectLink, error) { +func (q *Queries) ListProjectLinks(ctx context.Context, projectID string) ([]ProjectLink, error) { rows, err := q.db.Query(ctx, listProjectLinks, projectID) if err != nil { return nil, err @@ -386,14 +386,14 @@ ORDER BY t.name ` type ListProjectTagsRow struct { - ID pgtype.UUID - ProjectID pgtype.UUID - TagID pgtype.UUID + ID string + ProjectID string + TagID string CreatedAt pgtype.Timestamp TagName string } -func (q *Queries) ListProjectTags(ctx context.Context, projectID pgtype.UUID) ([]ListProjectTagsRow, error) { +func (q *Queries) ListProjectTags(ctx context.Context, projectID string) ([]ListProjectTagsRow, error) { rows, err := q.db.Query(ctx, listProjectTags, projectID) if err != nil { return nil, err @@ -458,7 +458,7 @@ WHERE company_id = $1 ORDER BY created_at DESC ` -func (q *Queries) ListProjectsByCompany(ctx context.Context, companyID pgtype.UUID) ([]Project, error) { +func (q *Queries) ListProjectsByCompany(ctx context.Context, companyID string) ([]Project, error) { rows, err := q.db.Query(ctx, listProjectsByCompany, companyID) if err != nil { return nil, err @@ -498,9 +498,9 @@ RETURNING id, company_id, title, description, status, created_at, updated_at ` type UpdateProjectParams struct { - ID pgtype.UUID + ID string Title string - Description pgtype.Text + Description *string Status string } diff --git a/db/resource_requests.sql.go b/db/resource_requests.sql.go index e468bfb..722f5f0 100644 --- a/db/resource_requests.sql.go +++ b/db/resource_requests.sql.go @@ -7,8 +7,6 @@ package db import ( "context" - - "github.com/jackc/pgx/v5/pgtype" ) const createResourceRequest = `-- name: CreateResourceRequest :one @@ -33,9 +31,9 @@ RETURNING id, company_id, resource_type, description, status, created_at, update ` type CreateResourceRequestParams struct { - CompanyID pgtype.UUID + CompanyID string ResourceType string - Description pgtype.Text + Description *string Status string } @@ -64,7 +62,7 @@ DELETE FROM resource_requests WHERE id = $1 ` -func (q *Queries) DeleteResourceRequest(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteResourceRequest(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteResourceRequest, id) return err } @@ -74,7 +72,7 @@ SELECT id, company_id, resource_type, description, status, created_at, updated_a WHERE id = $1 LIMIT 1 ` -func (q *Queries) GetResourceRequestByID(ctx context.Context, id pgtype.UUID) (ResourceRequest, error) { +func (q *Queries) GetResourceRequestByID(ctx context.Context, id string) (ResourceRequest, error) { row := q.db.QueryRow(ctx, getResourceRequestByID, id) var i ResourceRequest err := row.Scan( @@ -128,7 +126,7 @@ WHERE company_id = $1 ORDER BY updated_at DESC ` -func (q *Queries) ListResourceRequestsByCompany(ctx context.Context, companyID pgtype.UUID) ([]ResourceRequest, error) { +func (q *Queries) ListResourceRequestsByCompany(ctx context.Context, companyID string) ([]ResourceRequest, error) { rows, err := q.db.Query(ctx, listResourceRequestsByCompany, companyID) if err != nil { return nil, err @@ -166,7 +164,7 @@ RETURNING id, company_id, resource_type, description, status, created_at, update ` type UpdateResourceRequestStatusParams struct { - ID pgtype.UUID + ID string Status string } diff --git a/db/tags.sql.go b/db/tags.sql.go index 145ba6d..c8e94b1 100644 --- a/db/tags.sql.go +++ b/db/tags.sql.go @@ -7,8 +7,6 @@ package db import ( "context" - - "github.com/jackc/pgx/v5/pgtype" ) const createTag = `-- name: CreateTag :one @@ -37,7 +35,7 @@ DELETE FROM tags WHERE id = $1 ` -func (q *Queries) DeleteTag(ctx context.Context, id pgtype.UUID) error { +func (q *Queries) DeleteTag(ctx context.Context, id string) error { _, err := q.db.Exec(ctx, deleteTag, id) return err } @@ -47,7 +45,7 @@ SELECT id, name, created_at, updated_at FROM tags WHERE id = $1 LIMIT 1 ` -func (q *Queries) GetTag(ctx context.Context, id pgtype.UUID) (Tag, error) { +func (q *Queries) GetTag(ctx context.Context, id string) (Tag, error) { row := q.db.QueryRow(ctx, getTag, id) var i Tag err := row.Scan( diff --git a/db/users.sql.go b/db/users.sql.go index 6ca964f..7265ade 100644 --- a/db/users.sql.go +++ b/db/users.sql.go @@ -7,8 +7,6 @@ package db import ( "context" - - "github.com/jackc/pgx/v5/pgtype" ) const createUser = `-- name: CreateUser :one @@ -26,8 +24,8 @@ INSERT INTO users ( type CreateUserParams struct { Email string PasswordHash string - FirstName pgtype.Text - LastName pgtype.Text + FirstName *string + LastName *string Role string } @@ -81,7 +79,7 @@ SELECT id, email, password_hash, first_name, last_name, role, wallet_address, cr WHERE id = $1 LIMIT 1 ` -func (q *Queries) GetUserByID(ctx context.Context, id pgtype.UUID) (User, error) { +func (q *Queries) GetUserByID(ctx context.Context, id string) (User, error) { row := q.db.QueryRow(ctx, getUserByID, id) var i User err := row.Scan( diff --git a/go.mod b/go.mod index 966a5d5..618cb69 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/KonferCA/NoKap go 1.23.2 require ( - github.com/emicklei/pgtalk v1.5.0 github.com/go-playground/validator/v10 v10.22.1 github.com/golang-jwt/jwt/v5 v5.2.1 + github.com/google/uuid v1.6.0 github.com/jackc/pgx/v5 v5.7.1 github.com/joho/godotenv v1.5.1 github.com/labstack/echo/v4 v4.12.0 @@ -20,7 +20,6 @@ require ( github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/golang-jwt/jwt v3.2.2+incompatible // indirect - github.com/google/uuid v1.6.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/puddle/v2 v2.2.2 // indirect diff --git a/go.sum b/go.sum index 4e8c50b..dc39b8e 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/pgtalk v1.5.0 h1:qD2YUvB3VFZYxRmLKymlUrsVBgfXPec1SWkPFD58SQI= -github.com/emicklei/pgtalk v1.5.0/go.mod h1:Gl6hNbBV10II4aLKBxf4lQub6b2hxKD6NJ98P/PNML0= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= diff --git a/internal/server/auth.go b/internal/server/auth.go index f06edd5..d59c2fa 100644 --- a/internal/server/auth.go +++ b/internal/server/auth.go @@ -6,7 +6,6 @@ import ( "github.com/KonferCA/NoKap/db" "github.com/KonferCA/NoKap/internal/jwt" - "github.com/emicklei/pgtalk/convert" "github.com/jackc/pgx/v5/pgtype" "github.com/labstack/echo/v4" "golang.org/x/crypto/bcrypt" @@ -31,7 +30,7 @@ func (s *Server) handleSignup(c echo.Context) error { ctx := context.Background() existingUser, err := s.queries.GetUserByEmail(ctx, req.Email) - if err == nil && existingUser.ID.Valid { + if err == nil && existingUser.ID != "" { return echo.NewHTTPError(http.StatusConflict, "email already registered") } @@ -43,16 +42,15 @@ func (s *Server) handleSignup(c echo.Context) error { user, err := s.queries.CreateUser(ctx, db.CreateUserParams{ Email: req.Email, PasswordHash: string(hashedPassword), - FirstName: pgtype.Text{String: req.FirstName, Valid: true}, - LastName: pgtype.Text{String: req.LastName, Valid: true}, + FirstName: &req.FirstName, + LastName: &req.LastName, Role: req.Role, }) if err != nil { return echo.NewHTTPError(http.StatusInternalServerError, "failed to create user") } - userID := convert.UUIDToString(user.ID) - accessToken, refreshToken, err := jwt.Generate(userID, user.Role) + accessToken, refreshToken, err := jwt.Generate(user.ID, user.Role) if err != nil { return echo.NewHTTPError(http.StatusInternalServerError, "failed to generate token") } @@ -61,12 +59,12 @@ func (s *Server) handleSignup(c echo.Context) error { AccessToken: accessToken, RefreshToken: refreshToken, User: User{ - ID: userID, + ID: user.ID, Email: user.Email, - FirstName: user.FirstName.String, - LastName: user.LastName.String, + FirstName: *user.FirstName, + LastName: *user.LastName, Role: user.Role, - WalletAddress: getStringPtr(user.WalletAddress), + WalletAddress: user.WalletAddress, }, }) } @@ -91,8 +89,7 @@ func (s *Server) handleSignin(c echo.Context) error { return echo.NewHTTPError(http.StatusUnauthorized, "invalid credentials") } - userID := convert.UUIDToString(user.ID) - accessToken, refreshToken, err := jwt.Generate(userID, user.Role) + accessToken, refreshToken, err := jwt.Generate(user.ID, user.Role) if err != nil { return echo.NewHTTPError(http.StatusInternalServerError, "failed to generate token") } @@ -101,12 +98,12 @@ func (s *Server) handleSignin(c echo.Context) error { AccessToken: accessToken, RefreshToken: refreshToken, User: User{ - ID: userID, + ID: user.ID, Email: user.Email, - FirstName: user.FirstName.String, - LastName: user.LastName.String, + FirstName: *user.FirstName, + LastName: *user.LastName, Role: user.Role, - WalletAddress: getStringPtr(user.WalletAddress), + WalletAddress: user.WalletAddress, }, }) } diff --git a/internal/server/company.go b/internal/server/company.go index fdc6440..2cf9d0c 100644 --- a/internal/server/company.go +++ b/internal/server/company.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/KonferCA/NoKap/db" - "github.com/jackc/pgx/v5/pgtype" "github.com/labstack/echo/v4" ) @@ -24,7 +23,7 @@ func (s *Server) handleCreateCompany(c echo.Context) error { params := db.CreateCompanyParams{ OwnerUserID: ownerUUID, Name: req.Name, - Description: pgtype.Text{String: req.Description, Valid: req.Description != ""}, + Description: req.Description, } company, err := queries.CreateCompany(context.Background(), params) diff --git a/internal/server/employee.go b/internal/server/employee.go index 9af84c1..c61b38c 100644 --- a/internal/server/employee.go +++ b/internal/server/employee.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/KonferCA/NoKap/db" - "github.com/jackc/pgx/v5/pgtype" "github.com/labstack/echo/v4" ) @@ -37,10 +36,7 @@ func (s *Server) handleCreateEmployee(c echo.Context) error { Name: req.Name, Email: req.Email, Role: req.Role, - Bio: pgtype.Text{ - String: req.Bio, - Valid: req.Bio != "", - }, + Bio: req.Bio, } employee, err := queries.CreateEmployee(context.Background(), params) @@ -113,10 +109,7 @@ func (s *Server) handleUpdateEmployee(c echo.Context) error { ID: employeeID, Name: req.Name, Role: req.Role, - Bio: pgtype.Text{ - String: req.Bio, - Valid: req.Bio != "", - }, + Bio: req.Bio, } employee, err := queries.UpdateEmployee(context.Background(), params) diff --git a/internal/server/handler_helpers.go b/internal/server/handler_helpers.go index 51a674b..5723c32 100644 --- a/internal/server/handler_helpers.go +++ b/internal/server/handler_helpers.go @@ -5,6 +5,7 @@ import ( "net/http" "time" + "github.com/google/uuid" "github.com/jackc/pgx/v5/pgtype" "github.com/labstack/echo/v4" ) @@ -23,16 +24,15 @@ func validateBody(c echo.Context, requestBodyType interface{}) error { return nil } -func validateUUID(id string, fieldName string) (pgtype.UUID, error) { - var uuid pgtype.UUID +func validateUUID(id string, fieldName string) (string, error) { if id == "" { - return uuid, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Missing %s ID :(", fieldName)) + return "", echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Missing %s ID :(", fieldName)) } - if err := uuid.Scan(id); err != nil { - return uuid, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid %s ID format :(", fieldName)) + if err := uuid.Validate(id); err != nil { + return "", echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid %s ID format :(", fieldName)) } - return uuid, nil + return id, nil } func handleDBError(err error, operation string, resourceType string) error { @@ -75,28 +75,21 @@ func validateNumeric(value string) (pgtype.Numeric, error) { return num, nil } -func validateTimestamp(timeStr string, fieldName string) (pgtype.Timestamp, error) { - var ts pgtype.Timestamp +func validateTimestamp(timeStr string, fieldName string) (*time.Time, error) { if timeStr == "" { - return ts, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Missing %s :(", fieldName)) + return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Missing %s :(", fieldName)) } parsedTime, err := time.Parse(time.RFC3339, timeStr) if err != nil { - return ts, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid %s format :(", fieldName)) + return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid %s format :(", fieldName)) } - ts.Time = parsedTime - ts.Valid = true - return ts, nil + return &parsedTime, nil } -func validateTimeRange(startTime, endTime pgtype.Timestamp) error { - if !startTime.Valid || !endTime.Valid { - return echo.NewHTTPError(http.StatusBadRequest, "Invalid time values :(") - } - - if endTime.Time.Before(startTime.Time) { +func validateTimeRange(startTime, endTime time.Time) error { + if endTime.Before(startTime) { return echo.NewHTTPError(http.StatusBadRequest, "End time cannot be before start time :(") } diff --git a/internal/server/index.go b/internal/server/index.go index 33ae1a5..72d7520 100644 --- a/internal/server/index.go +++ b/internal/server/index.go @@ -73,7 +73,6 @@ func New(testing bool) (*Server, error) { e.Use(apiLimiter.RateLimit()) // global rate limit customValidator := middleware.NewRequestBodyValidator() - fmt.Printf("Initializing validator: %+v\n", customValidator) e.Validator = customValidator server := &Server{ @@ -108,12 +107,6 @@ func New(testing bool) (*Server, error) { func (s *Server) setupV1Routes() { s.apiV1 = s.echoInstance.Group("/api/v1") - s.echoInstance.GET("/", func(c echo.Context) error { - return c.JSON(200, map[string]string{ - "message": "Server do be running...", - }) - }) - for _, route := range s.echoInstance.Routes() { s.echoInstance.Logger.Printf("Route: %s %s", route.Method, route.Path) } diff --git a/internal/server/meetings.go b/internal/server/meetings.go index a98ee20..2705f02 100644 --- a/internal/server/meetings.go +++ b/internal/server/meetings.go @@ -3,9 +3,9 @@ package server import ( "context" "net/http" + "time" "github.com/KonferCA/NoKap/db" - "github.com/jackc/pgx/v5/pgtype" "github.com/labstack/echo/v4" ) @@ -25,12 +25,12 @@ func (s *Server) handleCreateMeeting(c echo.Context) error { return err } - startTime, err := validateTimestamp(req.StartTime, "start time") + startTime, err := time.Parse(time.RFC3339, req.StartTime) if err != nil { return err } - endTime, err := validateTimestamp(req.EndTime, "end time") + endTime, err := time.Parse(time.RFC3339, req.EndTime) if err != nil { return err } @@ -51,18 +51,9 @@ func (s *Server) handleCreateMeeting(c echo.Context) error { ScheduledByUserID: userID, StartTime: startTime, EndTime: endTime, - MeetingUrl: pgtype.Text{ - String: req.MeetingURL, - Valid: req.MeetingURL != "", - }, - Location: pgtype.Text{ - String: req.Location, - Valid: req.Location != "", - }, - Notes: pgtype.Text{ - String: req.Notes, - Valid: req.Notes != "", - }, + MeetingUrl: req.MeetingURL, + Location: req.Location, + Notes: req.Notes, } meeting, err := queries.CreateMeeting(context.Background(), params) @@ -130,12 +121,12 @@ func (s *Server) handleUpdateMeeting(c echo.Context) error { return err } - startTime, err := validateTimestamp(req.StartTime, "start time") + startTime, err := time.Parse(time.RFC3339, req.StartTime) if err != nil { return err } - endTime, err := validateTimestamp(req.EndTime, "end time") + endTime, err := time.Parse(time.RFC3339, req.EndTime) if err != nil { return err } @@ -152,21 +143,12 @@ func (s *Server) handleUpdateMeeting(c echo.Context) error { } params := db.UpdateMeetingParams{ - ID: meetingID, - StartTime: startTime, - EndTime: endTime, - MeetingUrl: pgtype.Text{ - String: req.MeetingURL, - Valid: req.MeetingURL != "", - }, - Location: pgtype.Text{ - String: req.Location, - Valid: req.Location != "", - }, - Notes: pgtype.Text{ - String: req.Notes, - Valid: req.Notes != "", - }, + ID: meetingID, + StartTime: startTime, + EndTime: endTime, + MeetingUrl: req.MeetingURL, + Location: req.Location, + Notes: req.Notes, } meeting, err := queries.UpdateMeeting(context.Background(), params) diff --git a/internal/server/projects.go b/internal/server/projects.go index d4d1dca..9f0d1dd 100644 --- a/internal/server/projects.go +++ b/internal/server/projects.go @@ -6,7 +6,6 @@ import ( "net/http" "github.com/KonferCA/NoKap/db" - "github.com/jackc/pgx/v5/pgtype" "github.com/labstack/echo/v4" ) @@ -32,13 +31,10 @@ func (s *Server) handleCreateProject(c echo.Context) error { companyID, req.Title, req.Status) params := db.CreateProjectParams{ - CompanyID: companyID, - Title: req.Title, - Description: pgtype.Text{ - String: req.Description, - Valid: req.Description != "", - }, - Status: req.Status, + CompanyID: companyID, + Title: req.Title, + Description: req.Description, + Status: req.Status, } project, err := queries.CreateProject(context.Background(), params) diff --git a/internal/server/resource_request.go b/internal/server/resource_request.go index 859b7d6..336ffc3 100644 --- a/internal/server/resource_request.go +++ b/internal/server/resource_request.go @@ -5,7 +5,6 @@ import ( "net/http" "github.com/KonferCA/NoKap/db" - "github.com/jackc/pgx/v5/pgtype" "github.com/labstack/echo/v4" ) @@ -29,7 +28,7 @@ func (s *Server) handleCreateResourceRequest(c echo.Context) error { params := db.CreateResourceRequestParams{ CompanyID: companyID, ResourceType: req.ResourceType, - Description: pgtype.Text{String: req.Description, Valid: req.Description != ""}, + Description: req.Description, Status: req.Status, } diff --git a/internal/server/startup.go b/internal/server/startup.go index 1d88579..3b3f4ff 100644 --- a/internal/server/startup.go +++ b/internal/server/startup.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/KonferCA/NoKap/db" - "github.com/jackc/pgx/v5/pgtype" + "github.com/google/uuid" "github.com/labstack/echo/v4" ) @@ -19,16 +19,15 @@ func (s *Server) handleCreateStartup(c echo.Context) error { return echo.NewHTTPError(http.StatusBadRequest, err.Error()) } - var ownerUUID pgtype.UUID - if err := ownerUUID.Scan(req.OwnerUserID); err != nil { + if err := uuid.Validate(req.OwnerUserID); err != nil { return echo.NewHTTPError(http.StatusBadRequest, "invalid owner ID format") } queries := db.New(s.DBPool) params := db.CreateCompanyParams{ - OwnerUserID: ownerUUID, + OwnerUserID: req.OwnerUserID, Name: req.Name, - Description: pgtype.Text{String: req.Description, Valid: true}, + Description: req.Description, } company, err := queries.CreateCompany(context.Background(), params) diff --git a/internal/server/types.go b/internal/server/types.go index 9995d85..d97fad1 100644 --- a/internal/server/types.go +++ b/internal/server/types.go @@ -28,16 +28,16 @@ type HealthReport struct { } type CreateCompanyRequest struct { - OwnerUserID string `json:"owner_user_id" validate:"required,uuid"` - Name string `json:"name" validate:"required"` - Description string `json:"description"` + OwnerUserID string `json:"owner_user_id" validate:"required,uuid"` + Name string `json:"name" validate:"required"` + Description *string `json:"description"` } type CreateResourceRequestRequest struct { - CompanyID string `json:"company_id" validate:"required,uuid"` - ResourceType string `json:"resource_type" validate:"required"` - Description string `json:"description"` - Status string `json:"status" validate:"required"` + CompanyID string `json:"company_id" validate:"required,uuid"` + ResourceType string `json:"resource_type" validate:"required"` + Description *string `json:"description"` + Status string `json:"status" validate:"required"` } type SignupRequest struct { @@ -80,17 +80,17 @@ type CreateCompanyFinancialsRequest struct { } type CreateEmployeeRequest struct { - CompanyID string `json:"company_id" validate:"required,uuid"` - Name string `json:"name" validate:"required"` - Email string `json:"email" validate:"required,email"` - Role string `json:"role" validate:"required"` - Bio string `json:"bio"` + CompanyID string `json:"company_id" validate:"required,uuid"` + Name string `json:"name" validate:"required"` + Email string `json:"email" validate:"required,email"` + Role string `json:"role" validate:"required"` + Bio *string `json:"bio"` } type UpdateEmployeeRequest struct { - Name string `json:"name" validate:"required"` - Role string `json:"role" validate:"required"` - Bio string `json:"bio"` + Name string `json:"name" validate:"required"` + Role string `json:"role" validate:"required"` + Bio *string `json:"bio"` } type CreateCompanyDocumentRequest struct { @@ -118,10 +118,10 @@ type UpdateCompanyAnswerRequest struct { } type CreateProjectRequest struct { - CompanyID string `json:"company_id" validate:"required"` - Title string `json:"title" validate:"required"` - Description string `json:"description"` - Status string `json:"status" validate:"required"` + CompanyID string `json:"company_id" validate:"required"` + Title string `json:"title" validate:"required"` + Description *string `json:"description"` + Status string `json:"status" validate:"required"` } type UpdateProjectRequest struct { @@ -168,19 +168,19 @@ type UpdateFundingTransactionStatusRequest struct { } type CreateMeetingRequest struct { - ProjectID string `json:"project_id" validate:"required,uuid"` - ScheduledByUserID string `json:"scheduled_by_user_id" validate:"required,uuid"` - StartTime string `json:"start_time" validate:"required,datetime=2006-01-02T15:04:05.000Z"` - EndTime string `json:"end_time" validate:"required,datetime=2006-01-02T15:04:05.000Z"` - MeetingURL string `json:"meeting_url" validate:"omitempty,url"` - Location string `json:"location"` - Notes string `json:"notes"` + ProjectID string `json:"project_id" validate:"required,uuid"` + ScheduledByUserID string `json:"scheduled_by_user_id" validate:"required,uuid"` + StartTime string `json:"start_time" validate:"required,datetime=2006-01-02T15:04:05.000Z"` + EndTime string `json:"end_time" validate:"required,datetime=2006-01-02T15:04:05.000Z"` + MeetingURL *string `json:"meeting_url" validate:"omitempty,url"` + Location *string `json:"location"` + Notes *string `json:"notes"` } type UpdateMeetingRequest struct { - StartTime string `json:"start_time" validate:"required,datetime=2006-01-02T15:04:05.000Z"` - EndTime string `json:"end_time" validate:"required,datetime=2006-01-02T15:04:05.000Z"` - MeetingURL string `json:"meeting_url" validate:"omitempty,url"` - Location string `json:"location"` - Notes string `json:"notes"` + StartTime string `json:"start_time" validate:"required,datetime=2006-01-02T15:04:05.000Z"` + EndTime string `json:"end_time" validate:"required,datetime=2006-01-02T15:04:05.000Z"` + MeetingURL *string `json:"meeting_url" validate:"omitempty,url"` + Location *string `json:"location"` + Notes *string `json:"notes"` } diff --git a/sqlc.yml b/sqlc.yml index 2a6bcdb..cd97b74 100644 --- a/sqlc.yml +++ b/sqlc.yml @@ -8,3 +8,15 @@ sql: package: "db" out: "db" sql_package: "pgx/v5" + emit_pointers_for_null_types: true + overrides: + - db_type: "uuid" + go_type: "string" + - db_type: "text" + go_type: "string" + - db_type: "pg_catalog.varchar" + go_type: "string" + - db_type: "pg_catalog.bpchar" + go_type: "string" + - db_type: "pg_catalog.timestamp" + go_type: "time.Time"