github.com/sujit-baniya/migrate@v0.0.4/source/go_bindata/examples/migrations/bindata.go (about)

     1  // Code generated by go-bindata.
     2  // sources:
     3  // 1085649617_create_users_table.down.sql
     4  // 1085649617_create_users_table.up.sql
     5  // 1185749658_add_city_to_users.down.sql
     6  // 1185749658_add_city_to_users.up.sql
     7  // DO NOT EDIT!
     8  
     9  package testdata
    10  
    11  import (
    12  	"bytes"
    13  	"compress/gzip"
    14  	"fmt"
    15  	"io"
    16  	"os"
    17  	"path/filepath"
    18  	"strings"
    19  	"time"
    20  )
    21  
    22  func bindataRead(data []byte, name string) ([]byte, error) {
    23  	gz, err := gzip.NewReader(bytes.NewBuffer(data))
    24  	if err != nil {
    25  		return nil, fmt.Errorf("Read %q: %v", name, err)
    26  	}
    27  
    28  	var buf bytes.Buffer
    29  	_, err = io.Copy(&buf, gz)
    30  	clErr := gz.Close()
    31  
    32  	if err != nil {
    33  		return nil, fmt.Errorf("Read %q: %v", name, err)
    34  	}
    35  	if clErr != nil {
    36  		return nil, err
    37  	}
    38  
    39  	return buf.Bytes(), nil
    40  }
    41  
    42  type asset struct {
    43  	bytes []byte
    44  	info  os.FileInfo
    45  }
    46  
    47  type bindataFileInfo struct {
    48  	name    string
    49  	size    int64
    50  	mode    os.FileMode
    51  	modTime time.Time
    52  }
    53  
    54  func (fi bindataFileInfo) Name() string {
    55  	return fi.name
    56  }
    57  func (fi bindataFileInfo) Size() int64 {
    58  	return fi.size
    59  }
    60  func (fi bindataFileInfo) Mode() os.FileMode {
    61  	return fi.mode
    62  }
    63  func (fi bindataFileInfo) ModTime() time.Time {
    64  	return fi.modTime
    65  }
    66  func (fi bindataFileInfo) IsDir() bool {
    67  	return false
    68  }
    69  func (fi bindataFileInfo) Sys() interface{} {
    70  	return nil
    71  }
    72  
    73  var __1085649617_create_users_tableDownSql = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x72\x09\xf2\x0f\x50\x08\x71\x74\xf2\x71\x55\xf0\x74\x53\x70\x8d\xf0\x0c\x0e\x09\x56\x28\x2d\x4e\x2d\x2a\xb6\xe6\x02\x04\x00\x00\xff\xff\x2c\x02\x3d\xa7\x1c\x00\x00\x00")
    74  
    75  func _1085649617_create_users_tableDownSqlBytes() ([]byte, error) {
    76  	return bindataRead(
    77  		__1085649617_create_users_tableDownSql,
    78  		"1085649617_create_users_table.down.sql",
    79  	)
    80  }
    81  
    82  func _1085649617_create_users_tableDownSql() (*asset, error) {
    83  	bytes, err := _1085649617_create_users_tableDownSqlBytes()
    84  	if err != nil {
    85  		return nil, err
    86  	}
    87  
    88  	info := bindataFileInfo{name: "1085649617_create_users_table.down.sql", size: 28, mode: os.FileMode(420), modTime: time.Unix(1485750305, 0)}
    89  	a := &asset{bytes: bytes, info: info}
    90  	return a, nil
    91  }
    92  
    93  var __1085649617_create_users_tableUpSql = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x72\x0e\x72\x75\x0c\x71\x55\x08\x71\x74\xf2\x71\x55\x28\x2d\x4e\x2d\x2a\x56\xd0\xe0\x52\x00\xb3\xe2\x33\x53\x14\x32\xf3\x4a\x52\xd3\x53\x8b\x14\x4a\xf3\x32\x0b\x4b\x53\x75\xb8\x14\x14\xf2\x12\x73\x53\x15\x14\x14\x14\xca\x12\x8b\x92\x33\x12\x8b\x34\x4c\x0c\x34\x41\xc2\xa9\xb9\x89\x99\x39\xa8\xc2\x5c\x9a\xd6\x5c\x80\x00\x00\x00\xff\xff\xa3\x57\xbc\x0b\x5f\x00\x00\x00")
    94  
    95  func _1085649617_create_users_tableUpSqlBytes() ([]byte, error) {
    96  	return bindataRead(
    97  		__1085649617_create_users_tableUpSql,
    98  		"1085649617_create_users_table.up.sql",
    99  	)
   100  }
   101  
   102  func _1085649617_create_users_tableUpSql() (*asset, error) {
   103  	bytes, err := _1085649617_create_users_tableUpSqlBytes()
   104  	if err != nil {
   105  		return nil, err
   106  	}
   107  
   108  	info := bindataFileInfo{name: "1085649617_create_users_table.up.sql", size: 95, mode: os.FileMode(420), modTime: time.Unix(1485803085, 0)}
   109  	a := &asset{bytes: bytes, info: info}
   110  	return a, nil
   111  }
   112  
   113  var __1185749658_add_city_to_usersDownSql = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x28\x2d\x4e\x2d\x2a\x56\x70\x09\xf2\x0f\x50\x70\xf6\xf7\x09\xf5\xf5\x53\xf0\x74\x53\x70\x8d\xf0\x0c\x0e\x09\x56\x48\xce\x2c\xa9\xb4\xe6\x02\x04\x00\x00\xff\xff\xb7\x52\x88\xd7\x2e\x00\x00\x00")
   114  
   115  func _1185749658_add_city_to_usersDownSqlBytes() ([]byte, error) {
   116  	return bindataRead(
   117  		__1185749658_add_city_to_usersDownSql,
   118  		"1185749658_add_city_to_users.down.sql",
   119  	)
   120  }
   121  
   122  func _1185749658_add_city_to_usersDownSql() (*asset, error) {
   123  	bytes, err := _1185749658_add_city_to_usersDownSqlBytes()
   124  	if err != nil {
   125  		return nil, err
   126  	}
   127  
   128  	info := bindataFileInfo{name: "1185749658_add_city_to_users.down.sql", size: 46, mode: os.FileMode(420), modTime: time.Unix(1485750443, 0)}
   129  	a := &asset{bytes: bytes, info: info}
   130  	return a, nil
   131  }
   132  
   133  var __1185749658_add_city_to_usersUpSql = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x28\x2d\x4e\x2d\x2a\x56\x70\x74\x71\x51\x70\xf6\xf7\x09\xf5\xf5\x53\x48\xce\x2c\xa9\x54\x28\x4b\x2c\x4a\xce\x48\x2c\xd2\x30\x34\x30\xd0\xb4\xe6\xe2\xe2\x02\x04\x00\x00\xff\xff\xa8\x0f\x49\xc6\x32\x00\x00\x00")
   134  
   135  func _1185749658_add_city_to_usersUpSqlBytes() ([]byte, error) {
   136  	return bindataRead(
   137  		__1185749658_add_city_to_usersUpSql,
   138  		"1185749658_add_city_to_users.up.sql",
   139  	)
   140  }
   141  
   142  func _1185749658_add_city_to_usersUpSql() (*asset, error) {
   143  	bytes, err := _1185749658_add_city_to_usersUpSqlBytes()
   144  	if err != nil {
   145  		return nil, err
   146  	}
   147  
   148  	info := bindataFileInfo{name: "1185749658_add_city_to_users.up.sql", size: 50, mode: os.FileMode(420), modTime: time.Unix(1485843733, 0)}
   149  	a := &asset{bytes: bytes, info: info}
   150  	return a, nil
   151  }
   152  
   153  // Asset loads and returns the asset for the given name.
   154  // It returns an error if the asset could not be found or
   155  // could not be loaded.
   156  func Asset(name string) ([]byte, error) {
   157  	cannonicalName := strings.Replace(name, "\\", "/", -1)
   158  	if f, ok := _bindata[cannonicalName]; ok {
   159  		a, err := f()
   160  		if err != nil {
   161  			return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
   162  		}
   163  		return a.bytes, nil
   164  	}
   165  	return nil, fmt.Errorf("Asset %s not found", name)
   166  }
   167  
   168  // MustAsset is like Asset but panics when Asset would return an error.
   169  // It simplifies safe initialization of global variables.
   170  func MustAsset(name string) []byte {
   171  	a, err := Asset(name)
   172  	if err != nil {
   173  		panic("asset: Asset(" + name + "): " + err.Error())
   174  	}
   175  
   176  	return a
   177  }
   178  
   179  // AssetInfo loads and returns the asset info for the given name.
   180  // It returns an error if the asset could not be found or
   181  // could not be loaded.
   182  func AssetInfo(name string) (os.FileInfo, error) {
   183  	cannonicalName := strings.Replace(name, "\\", "/", -1)
   184  	if f, ok := _bindata[cannonicalName]; ok {
   185  		a, err := f()
   186  		if err != nil {
   187  			return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
   188  		}
   189  		return a.info, nil
   190  	}
   191  	return nil, fmt.Errorf("AssetInfo %s not found", name)
   192  }
   193  
   194  // AssetNames returns the names of the assets.
   195  func AssetNames() []string {
   196  	names := make([]string, 0, len(_bindata))
   197  	for name := range _bindata {
   198  		names = append(names, name)
   199  	}
   200  	return names
   201  }
   202  
   203  // _bindata is a table, holding each asset generator, mapped to its name.
   204  var _bindata = map[string]func() (*asset, error){
   205  	"1085649617_create_users_table.down.sql": _1085649617_create_users_tableDownSql,
   206  	"1085649617_create_users_table.up.sql":   _1085649617_create_users_tableUpSql,
   207  	"1185749658_add_city_to_users.down.sql":  _1185749658_add_city_to_usersDownSql,
   208  	"1185749658_add_city_to_users.up.sql":    _1185749658_add_city_to_usersUpSql,
   209  }
   210  
   211  // AssetDir returns the file names below a certain
   212  // directory embedded in the file by go-bindata.
   213  // For example if you run go-bindata on data/... and data contains the
   214  // following hierarchy:
   215  //
   216  //	data/
   217  //	  foo.txt
   218  //	  img/
   219  //	    a.png
   220  //	    b.png
   221  //
   222  // then AssetDir("data") would return []string{"foo.txt", "img"}
   223  // AssetDir("data/img") would return []string{"a.png", "b.png"}
   224  // AssetDir("foo.txt") and AssetDir("notexist") would return an error
   225  // AssetDir("") will return []string{"data"}.
   226  func AssetDir(name string) ([]string, error) {
   227  	node := _bintree
   228  	if len(name) != 0 {
   229  		cannonicalName := strings.Replace(name, "\\", "/", -1)
   230  		pathList := strings.Split(cannonicalName, "/")
   231  		for _, p := range pathList {
   232  			node = node.Children[p]
   233  			if node == nil {
   234  				return nil, fmt.Errorf("Asset %s not found", name)
   235  			}
   236  		}
   237  	}
   238  	if node.Func != nil {
   239  		return nil, fmt.Errorf("Asset %s not found", name)
   240  	}
   241  	rv := make([]string, 0, len(node.Children))
   242  	for childName := range node.Children {
   243  		rv = append(rv, childName)
   244  	}
   245  	return rv, nil
   246  }
   247  
   248  type bintree struct {
   249  	Func     func() (*asset, error)
   250  	Children map[string]*bintree
   251  }
   252  
   253  var _bintree = &bintree{nil, map[string]*bintree{
   254  	"1085649617_create_users_table.down.sql": &bintree{_1085649617_create_users_tableDownSql, map[string]*bintree{}},
   255  	"1085649617_create_users_table.up.sql":   &bintree{_1085649617_create_users_tableUpSql, map[string]*bintree{}},
   256  	"1185749658_add_city_to_users.down.sql":  &bintree{_1185749658_add_city_to_usersDownSql, map[string]*bintree{}},
   257  	"1185749658_add_city_to_users.up.sql":    &bintree{_1185749658_add_city_to_usersUpSql, map[string]*bintree{}},
   258  }}
   259  
   260  // RestoreAsset restores an asset under the given directory
   261  func RestoreAsset(dir, name string) error {
   262  	data, err := Asset(name)
   263  	if err != nil {
   264  		return err
   265  	}
   266  	info, err := AssetInfo(name)
   267  	if err != nil {
   268  		return err
   269  	}
   270  	err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
   271  	if err != nil {
   272  		return err
   273  	}
   274  	err = os.WriteFile(_filePath(dir, name), data, info.Mode())
   275  	if err != nil {
   276  		return err
   277  	}
   278  	err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
   279  	if err != nil {
   280  		return err
   281  	}
   282  	return nil
   283  }
   284  
   285  // RestoreAssets restores an asset under the given directory recursively
   286  func RestoreAssets(dir, name string) error {
   287  	children, err := AssetDir(name)
   288  	// File
   289  	if err != nil {
   290  		return RestoreAsset(dir, name)
   291  	}
   292  	// Dir
   293  	for _, child := range children {
   294  		err = RestoreAssets(dir, filepath.Join(name, child))
   295  		if err != nil {
   296  			return err
   297  		}
   298  	}
   299  	return nil
   300  }
   301  
   302  func _filePath(dir, name string) string {
   303  	cannonicalName := strings.Replace(name, "\\", "/", -1)
   304  	return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
   305  }