MigrationFromFile builds a migration by reading from an open File-like object. The migration's ID will be based on the file's name. The file will *not* be closed after being read.
(file File)
| 65 | // object. The migration's ID will be based on the file's name. The file |
| 66 | // will *not* be closed after being read. |
| 67 | func MigrationFromFile(file File) (migration *Migration, err error) { |
| 68 | migration = &Migration{} |
| 69 | migration.ID = MigrationIDFromFilename(file.Name()) |
| 70 | content, err := io.ReadAll(file) |
| 71 | if err != nil { |
| 72 | return migration, err |
| 73 | } |
| 74 | migration.Script = string(content) |
| 75 | return migration, err |
| 76 | } |
searching dependent graphs…