github.com/abolfazlbeh/zhycan@v0.0.0-20230819144214-24cf38237387/internal/db/types.go (about)

     1  package db
     2  
     3  type Config struct {
     4  	SkipDefaultTransaction                   bool `json:"skip_default_transaction"`
     5  	DryRun                                   bool `json:"dry_run"`
     6  	PrepareStmt                              bool `json:"prepare_stmt"`
     7  	DisableAutomaticPing                     bool `json:"disable_automatic_ping"`
     8  	DisableForeignKeyConstraintWhenMigrating bool `json:"disable_foreign_key_constraint_when_migrating"`
     9  	IgnoreRelationshipsWhenMigrating         bool `json:"ignore_relationships_when_migrating"`
    10  	DisableNestedTransaction                 bool `json:"disable_nested_transaction"`
    11  }
    12  
    13  type LoggerConfig struct {
    14  	SlowThreshold             int64  `json:"slow_threshold"`
    15  	IgnoreRecordNotFoundError bool   `json:"ignore_record_not_found_error"`
    16  	ParameterizedQueries      bool   `json:"parameterized_queries"`
    17  	LogLevel                  string `json:"log_level"`
    18  }
    19  
    20  type MysqlSpecificConfig struct {
    21  	DefaultStringSize         uint `json:"default_string_size"`
    22  	DisableDatetimePrecision  bool `json:"disable_datetime_precision"`
    23  	DefaultDatetimePrecision  int  `json:"default_datetime_precision"`
    24  	SupportRenameIndex        bool `json:"support_rename_index"`
    25  	SupportRenameColumn       bool `json:"support_rename_column"`
    26  	SkipInitializeWithVersion bool `json:"skip_initialize_with_version"`
    27  	DisableWithReturning      bool `json:"disable_with_returning"`
    28  	SupportForShareClause     bool `json:"support_for_share_clause"`
    29  	SupportNullAsDefaultValue bool `json:"support_null_as_default_value"`
    30  	SupportRenameColumnUnique bool `json:"support_rename_column_unique"`
    31  }
    32  
    33  type PostgresqlSpecificConfig struct {
    34  	PreferSimpleProtocol bool `json:"prefer_simple_protocol"`
    35  	WithoutReturning     bool `json:"without_returning"`
    36  }
    37  
    38  type Sqlite struct {
    39  	FileName     string            `json:"db"`
    40  	Options      map[string]string `json:"options"`
    41  	Config       *Config           `json:"config"`
    42  	LoggerConfig *LoggerConfig     `json:"logger"`
    43  }
    44  
    45  type Mysql struct {
    46  	DatabaseName   string               `json:"db"`
    47  	Username       string               `json:"username"`
    48  	Password       string               `json:"password"`
    49  	Host           string               `json:"host"`
    50  	Port           string               `json:"port"`
    51  	Protocol       string               `json:"protocol"`
    52  	Options        map[string]string    `json:"options"`
    53  	Config         *Config              `json:"config"`
    54  	LoggerConfig   *LoggerConfig        `json:"logger"`
    55  	SpecificConfig *MysqlSpecificConfig `json:"specific_config"`
    56  }
    57  
    58  type Postgresql struct {
    59  	DatabaseName   string                    `json:"db"`
    60  	Username       string                    `json:"username"`
    61  	Password       string                    `json:"password"`
    62  	Host           string                    `json:"host"`
    63  	Port           string                    `json:"port"`
    64  	Options        map[string]string         `json:"options"`
    65  	Config         *Config                   `json:"config"`
    66  	LoggerConfig   *LoggerConfig             `json:"logger"`
    67  	SpecificConfig *PostgresqlSpecificConfig `json:"specific_config"`
    68  }
    69  
    70  type SqlConfigurable interface {
    71  	Sqlite | Mysql | Postgresql
    72  }
    73  
    74  type MongoLoggerConfig struct {
    75  	MaxDocumentLength   int    `json:"max_document_length"`
    76  	ComponentCommand    string `json:"component_command"`
    77  	ComponentConnection string `json:"component_connection"`
    78  }
    79  
    80  type Mongo struct {
    81  	DatabaseName string             `json:"db"`
    82  	Username     string             `json:"username"`
    83  	Password     string             `json:"password"`
    84  	Host         string             `json:"host"`
    85  	Port         string             `json:"port"`
    86  	Options      map[string]string  `json:"options"`
    87  	LoggerConfig *MongoLoggerConfig `json:"logger"`
    88  }