I am very new to this and trying to learn. Integrating SQLBoiler to the sample. My sql migration file is:
-- +migrate Up
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name text,
-- Auth
email text NOT NULL UNIQUE,
password text NOT NULL,
-- Confirm
Confirm_Selector text,
Confirm_Verifier text,
Confirmed BOOLEAN DEFAULT 'f',
-- Lock
Attempt_Count INT,
Last_Attempt DATE,
Locked DATE,
-- Recover
Recover_Selector text,
Recover_Verifier text,
Recover_Token_Expiry DATE,
-- OAuth2
O_Auth2_U_I_D text,
O_Auth2_Provider text,
O_Auth2_Access_Token text,
O_Auth2_Refresh_Token text,
O_Auth2_Expiry DATE,
-- 2fa
T_O_T_P_Secret_Key text,
S_M_S_Phone_Number text,
S_M_S_Seed_Phone_Number text,
Recovery_Codes text
);
-- +migrate Down
DROP TABLE users;
This produced the following User in package models
:
// User is an object representing the database table.
type User struct {
ID int `boil:"id" json:"id" toml:"id" yaml:"id"`
Name null.String `boil:"name" json:"name,omitempty" toml:"name" yaml:"name,omitempty"`
Email string `boil:"email" json:"email" toml:"email" yaml:"email"`
Password string `boil:"password" json:"password" toml:"password" yaml:"password"`
ConfirmSelector null.String `boil:"confirm_selector" json:"confirm_selector,omitempty" toml:"confirm_selector" yaml:"confirm_selector,omitempty"`
ConfirmVerifier null.String `boil:"confirm_verifier" json:"confirm_verifier,omitempty" toml:"confirm_verifier" yaml:"confirm_verifier,omitempty"`
Confirmed null.Bool `boil:"confirmed" json:"confirmed,omitempty" toml:"confirmed" yaml:"confirmed,omitempty"`
AttemptCount null.Int `boil:"attempt_count" json:"attempt_count,omitempty" toml:"attempt_count" yaml:"attempt_count,omitempty"`
LastAttempt null.Time `boil:"last_attempt" json:"last_attempt,omitempty" toml:"last_attempt" yaml:"last_attempt,omitempty"`
Locked null.Time `boil:"locked" json:"locked,omitempty" toml:"locked" yaml:"locked,omitempty"`
RecoverSelector null.String `boil:"recover_selector" json:"recover_selector,omitempty" toml:"recover_selector" yaml:"recover_selector,omitempty"`
RecoverVerifier null.String `boil:"recover_verifier" json:"recover_verifier,omitempty" toml:"recover_verifier" yaml:"recover_verifier,omitempty"`
RecoverTokenExpiry null.Time `boil:"recover_token_expiry" json:"recover_token_expiry,omitempty" toml:"recover_token_expiry" yaml:"recover_token_expiry,omitempty"`
OAuth2UID null.String `boil:"o_auth2_u_i_d" json:"o_auth2_u_i_d,omitempty" toml:"o_auth2_u_i_d" yaml:"o_auth2_u_i_d,omitempty"`
OAuth2Provider null.String `boil:"o_auth2_provider" json:"o_auth2_provider,omitempty" toml:"o_auth2_provider" yaml:"o_auth2_provider,omitempty"`
OAuth2AccessToken null.String `boil:"o_auth2_access_token" json:"o_auth2_access_token,omitempty" toml:"o_auth2_access_token" yaml:"o_auth2_access_token,omitempty"`
OAuth2RefreshToken null.String `boil:"o_auth2_refresh_token" json:"o_auth2_refresh_token,omitempty" toml:"o_auth2_refresh_token" yaml:"o_auth2_refresh_token,omitempty"`
OAuth2Expiry null.Time `boil:"o_auth2_expiry" json:"o_auth2_expiry,omitempty" toml:"o_auth2_expiry" yaml:"o_auth2_expiry,omitempty"`
TOTPSecretKey null.String `boil:"t_o_t_p_secret_key" json:"t_o_t_p_secret_key,omitempty" toml:"t_o_t_p_secret_key" yaml:"t_o_t_p_secret_key,omitempty"`
SMSPhoneNumber null.String `boil:"s_m_s_phone_number" json:"s_m_s_phone_number,omitempty" toml:"s_m_s_phone_number" yaml:"s_m_s_phone_number,omitempty"`
SMSSeedPhoneNumber null.String `boil:"s_m_s_seed_phone_number" json:"s_m_s_seed_phone_number,omitempty" toml:"s_m_s_seed_phone_number" yaml:"s_m_s_seed_phone_number,omitempty"`
RecoveryCodes null.String `boil:"recovery_codes" json:"recovery_codes,omitempty" toml:"recovery_codes" yaml:"recovery_codes,omitempty"`
R *userR `boil:"-" json:"-" toml:"-" yaml:"-"`
L userL `boil:"-" json:"-" toml:"-" yaml:"-"`
}
Does it look right? I am assuming that I can simply import the models
package into the main
package in the storer.go
file.