You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sqlite.go
    path of file: ./repos/chanify/model
    
    the code of the file until where you have to start completion: package model

import (
	"database/sql"
	"log"
	"strings"

	_ "modernc.org/sqlite" // sqlite driver
)

type sqlite struct {
	db *sql.DB
}

func init() {
	drivers["sqlite"] = func(dsn string) (DB, error) {
		items := strings.Split(dsn, "://")
		path := items[1]
		db, _ := sql.Open(items[0], "file:"+path)
		if err := db.Ping(); err != nil {
			return nil, err
		}
		log.Println("Open sqlite database:", path)
		s := &sqlite{db: db}
		if err := s.fixDB(); err != nil {
			return nil, err
		}
		return s, nil
	}
}

func (s *sqlite) Close() {
	if s.db != nil {
		s.db.Close()
		s.db = nil
		log.Println("Close sqlite database")
	}
}

func (s *sqlite) SetOption(key string, value interface{}) error {
	_, err := s.db.Exec("INSERT INTO `options`(`key`,`value`) VALUES(?,?) ON CONFLICT(`key`) DO UPDATE SET `value`=excluded.`value`;", key, value)
	return err
}

func (s *sqlite) GetOption(key string, value interface{}) error {
	row := s.db.QueryRow("SELECT `value` FROM `options` WHERE `key`=? LIMIT 1;", key)
	return row.Scan(value)

    
func (s *sqlite) fixDB() error {
	sqls := []string{
		"CREATE TABLE IF NOT EXISTS `options`(`key` TEXT PRIMARY KEY, `value` BLOB);",
		"CREATE TABLE IF NOT EXISTS `users`(`uid` TEXT PRIMARY KEY, `pubkey` BLOB UNIQUE, `seckey` BLOB, `flags` INTEGER DEFAULT 0, `lastupdate` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `createtime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP);",
		"CREATE TABLE IF NOT EXISTS `devices`(`uuid` TEXT PRIMARY KEY, `uid` TEXT, `key` BLOB, `type` INTEGER DEFAULT 0, `token` BLOB, `sandbox` INTEGER DEFAULT 0, `lastupdate` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `createtime` TIMESTAMP DEFAULT CURRENT_TIMESTAMP);",
		"CREATE INDEX IF NOT EXISTS `idx_devices_uid` ON `devices`(`uid`);",
	}
	if _, err := s.db.Exec(strings.Join(sqls, "")); err != nil {
		return err
	}
	tx, err := s.db.Begin()
	if err != nil {
		return err
	}
	cnt := 0
	row := tx.QueryRow("SELECT COUNT(*) FROM pragma_table_info('devices') WHERE `name`='type';")
	if err := row.Scan(&cnt); err != nil {
		tx.Rollback() // nolint: errcheck
		return err
	}
	if cnt <= 0 {
		if _, err := tx.Exec("ALTER TABLE `devices` ADD COLUMN `type` INTEGER DEFAULT 0;"); err != nil {
			tx.Rollback() // nolint: errcheck
			return err
		}
		log.Println("SQLite add column `type` into `devices`.")
	}
	return tx.Commit()
}