Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Sagleft committed Oct 29, 2021
2 parents 2db51c9 + 411cc66 commit e7569fe
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# simple-migrate
# simple-migrate

Migrations in a couple of clicks.
You will need a 'versions' table, a sample is given in the project directory.

Usage:

```go
// create db connection (*sql.DB)..
// conn := ...

handler := simplemigrate.NewMigrationHandler(simplemigrate.MigrationTask{
ScriptsDir: "./migrations/",
DBDriver: conn,
DBName: "mydb",
})
err := handler.Run()
if err != nil {
// handle error
}
```

The 'migrations' folder should contain the ".sql" files with the migrations.
For example:

```
000_tables.sql
001_modify_users.sql
002_add_counter.sql
```
9 changes: 9 additions & 0 deletions versions_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
create table if not exists `versions` (
`id` int(10) unsigned not null PRIMARY KEY auto_increment,
`name` varchar(128) not null default '',
`created` timestamp default current_timestamp
)
engine = innodb
auto_increment = 1
character set utf8
collate utf8_general_ci;

0 comments on commit e7569fe

Please sign in to comment.