func (db Database) Setup(ctx context.Context, files []io.Reader) error {
	ctx, cancelFunc := context.WithTimeout(ctx, db.QueryPeriod)
	defer cancelFunc()
	queries := make([]Query, len(files))
	for i, f := range files {
		b, err := io.ReadAll(f)
		if err != nil {
			return fmt.Errorf("reading sql setup query %v: %w", i, err)
		}
		queries[i] = RawQuery(b)
	}
	if err := db.Exec(ctx, queries...); err != nil {
		return fmt.Errorf("running setup queries %w", err)
	}
	return nil
}
// Setup initializes the database by reading the files and executing their contents as raw queries.
Setup initializes the database by reading the files and executing their contents as raw queries.
// Setup initializes the database by reading the files and executing their contents as raw queries .
func (db Database) Setup(ctx context.Context, files []io.Reader) error {
	ctx, cancelFunc := context.WithTimeout(ctx, db.QueryPeriod)
	defer cancelFunc()
	queries := make([]Query, len(files))
	for i, f := range files {
		b, err := io.ReadAll(f)
		if err != nil {
			return fmt.Errorf("reading sql setup query %v: %w", i, err)
		}
		queries[i] = RawQuery(b)
	}
	if err := db.Exec(ctx, queries...); err != nil {
		return fmt.Errorf("running setup queries %w", err)
	}
	return nil
}
func ( db Database ) Setup ( ctx context . Context , files [ ] io . Reader ) error { ctx , cancelFunc := context . WithTimeout ( ctx , db . QueryPeriod ) defer cancelFunc ( ) queries := make ( [ ] Query , len ( files ) ) for i , f := range files { b , err := io . ReadAll ( f ) if err != nil { return fmt . Errorf ( " " , i , err ) } queries [ i ] = RawQuery ( b ) } if err := db . Exec ( ctx , queries ... ) ; err != nil { return fmt . Errorf ( " " , err ) } return nil }
Setup initializes the database by reading the files and executing their contents as raw queries.
Setup initializes the database by reading the files and executing their contents as raw queries .