This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
forked from rubenv/sql-migrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
122 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* | ||
!go.mod | ||
!go.sum | ||
!*.go | ||
!sql-migrate/*.go | ||
!sqlparse/*.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Release | ||
|
||
on: | ||
release: | ||
types: [ created ] | ||
|
||
jobs: | ||
releases-matrix: | ||
name: Release Go Binary | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
goos: [ linux, windows, darwin ] | ||
goarch: [ amd64 ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- uses: wangyoucao577/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
goos: ${{ matrix.goos }} | ||
goarch: ${{ matrix.goarch }} | ||
goversion: 1.16 | ||
pre_command: export CGO_ENABLED=0 | ||
project_path: "./sql-migrate" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.*.swp | ||
*.test | ||
.idea | ||
/vendor/ | ||
|
||
/sql-migrate/test.db | ||
/test.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ sudo: false | |
go: | ||
- "1.13" | ||
- "1.14" | ||
- "1.15" | ||
- "1.16" | ||
|
||
services: | ||
- mysql | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ARG GO_VERSION=1.16.2 | ||
ARG ALPINE_VERSION=3.12 | ||
|
||
### Vendor | ||
FROM golang:${GO_VERSION} as vendor | ||
COPY . /project | ||
WORKDIR /project | ||
RUN go mod tidy && go mod vendor | ||
|
||
### Build binary | ||
FROM golang:${GO_VERSION} as build-binary | ||
COPY . /project | ||
COPY --from=vendor /project/vendor /project/vendor | ||
WORKDIR /project | ||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build \ | ||
-v \ | ||
-mod vendor \ | ||
-o /project/bin/sql-migrate \ | ||
/project/sql-migrate | ||
|
||
### Image | ||
FROM alpine:${ALPINE_VERSION} as image | ||
COPY --from=build-binary /project/bin/sql-migrate /usr/local/bin/sql-migrate | ||
RUN chmod +x /usr/local/bin/sql-migrate | ||
ENTRYPOINT ["sql-migrate"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
MIT License | ||
|
||
Copyright (C) 2014-2019 by Ruben Vermeersch <[email protected]> | ||
Copyright (C) 2014-2021 by Ruben Vermeersch <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// +build go1.16 | ||
|
||
package migrate | ||
|
||
import ( | ||
"embed" | ||
"net/http" | ||
) | ||
|
||
// A set of migrations loaded from an go1.16 embed.FS | ||
|
||
type EmbedFileSystemMigrationSource struct { | ||
FileSystem embed.FS | ||
|
||
Root string | ||
} | ||
|
||
var _ MigrationSource = (*EmbedFileSystemMigrationSource)(nil) | ||
|
||
func (f EmbedFileSystemMigrationSource) FindMigrations() ([]*Migration, error) { | ||
return findMigrations(http.FS(f.FileSystem), f.Root) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// +build go1.16 | ||
|
||
package migrate | ||
|
||
import ( | ||
"embed" | ||
|
||
. "gopkg.in/check.v1" | ||
) | ||
|
||
//go:embed test-migrations/* | ||
var testEmbedFS embed.FS | ||
|
||
func (s *SqliteMigrateSuite) TestEmbedSource(c *C) { | ||
migrations := EmbedFileSystemMigrationSource{ | ||
FileSystem: testEmbedFS, | ||
Root: "test-migrations", | ||
} | ||
|
||
// Executes two migrations | ||
n, err := Exec(s.Db, "sqlite3", migrations, Up) | ||
c.Assert(err, IsNil) | ||
c.Assert(n, Equals, 2) | ||
|
||
// Has data | ||
id, err := s.DbMap.SelectInt("SELECT id FROM people") | ||
c.Assert(err, IsNil) | ||
c.Assert(id, Equals, int64(1)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters