mirror of
https://github.com/usememos/memos.git
synced 2025-10-07 04:51:40 +08:00
chore: release v0.1.3 (#98)
* chore: update github action * chore: release `v0.1.3` * fix: create migration_history table * fix: compare migration_history
This commit is contained in:
parent
87e6277977
commit
9611ff7386
6 changed files with 21 additions and 21 deletions
|
@ -21,7 +21,7 @@ jobs:
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_NEOSMEMO_USERNAME }}
|
username: neosmemo
|
||||||
password: ${{ secrets.DOCKER_NEOSMEMO_TOKEN }}
|
password: ${{ secrets.DOCKER_NEOSMEMO_TOKEN }}
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
|
@ -35,4 +35,4 @@ jobs:
|
||||||
context: ./
|
context: ./
|
||||||
file: ./Dockerfile
|
file: ./Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ secrets.DOCKER_NEOSMEMO_USERNAME }}/memos:${{ env.VERSION }}
|
tags: neosmemo/memos:${{ env.VERSION }}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
## ⚓️ Deploy with Docker
|
## ⚓️ Deploy with Docker
|
||||||
|
|
||||||
```docker
|
```docker
|
||||||
docker run --name memos --publish 5230:5230 --volume ~/.memos/:/var/opt/memos -e mode=prod -e port=5230 neosmemo/memos:0.1.2
|
docker run --name memos --publish 5230:5230 --volume ~/.memos/:/var/opt/memos -e mode=prod -e port=5230 neosmemo/memos:0.1.3
|
||||||
```
|
```
|
||||||
|
|
||||||
Memos should now be running at [http://localhost:5230](http://localhost:5230). If the `~/.memos/` does not have a `memos_prod.db` file, then `memos` will auto generate it.
|
Memos should now be running at [http://localhost:5230](http://localhost:5230). If the `~/.memos/` does not have a `memos_prod.db` file, then `memos` will auto generate it.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package common
|
package common
|
||||||
|
|
||||||
// Version is the service current released version.
|
// Version is the service current released version.
|
||||||
var Version = "0.1.2"
|
var Version = "0.1.3"
|
||||||
|
|
|
@ -75,15 +75,15 @@ func (db *DB) Open() (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
err = db.compareMigrationHistory()
|
||||||
}
|
|
||||||
|
|
||||||
func (db *DB) migrate() error {
|
|
||||||
err := db.compareMigrationHistory()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to compare migration history, err=%w", err)
|
return fmt.Errorf("failed to compare migration history, err=%w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (db *DB) migrate() error {
|
||||||
filenames, err := fs.Glob(migrationFS, fmt.Sprintf("%s/*.sql", "migration"))
|
filenames, err := fs.Glob(migrationFS, fmt.Sprintf("%s/*.sql", "migration"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -137,12 +137,12 @@ func (db *DB) executeFile(FS embed.FS, name string) error {
|
||||||
|
|
||||||
// compareMigrationHistory compares migration history data
|
// compareMigrationHistory compares migration history data
|
||||||
func (db *DB) compareMigrationHistory() error {
|
func (db *DB) compareMigrationHistory() error {
|
||||||
table, err := findTable(db, "migration_history")
|
table, err := findTable(db.Db, "migration_history")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if table == nil {
|
if table == nil {
|
||||||
if err := createTable(db, `
|
if err := createTable(db.Db, `
|
||||||
CREATE TABLE migration_history (
|
CREATE TABLE migration_history (
|
||||||
version TEXT NOT NULL PRIMARY KEY,
|
version TEXT NOT NULL PRIMARY KEY,
|
||||||
created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now'))
|
created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now'))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"database/sql"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -10,13 +10,13 @@ type Table struct {
|
||||||
SQL string
|
SQL string
|
||||||
}
|
}
|
||||||
|
|
||||||
func findTable(db *DB, tableName string) (*Table, error) {
|
func findTable(db *sql.DB, tableName string) (*Table, error) {
|
||||||
where, args := []string{"1 = 1"}, []interface{}{}
|
where, args := []string{"1 = 1"}, []interface{}{}
|
||||||
|
|
||||||
where, args = append(where, "type = ?"), append(args, "table")
|
where, args = append(where, "type = ?"), append(args, "table")
|
||||||
where, args = append(where, "name = ?"), append(args, tableName)
|
where, args = append(where, "name = ?"), append(args, tableName)
|
||||||
|
|
||||||
rows, err := db.Db.Query(`
|
rows, err := db.Query(`
|
||||||
SELECT
|
SELECT
|
||||||
tbl_name,
|
tbl_name,
|
||||||
sql
|
sql
|
||||||
|
@ -53,13 +53,13 @@ func findTable(db *DB, tableName string) (*Table, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTable(db *DB, sql string) error {
|
func createTable(db *sql.DB, sql string) error {
|
||||||
result, err := db.Db.Exec(sql)
|
result, err := db.Exec(sql)
|
||||||
|
if err != nil {
|
||||||
rows, _ := result.RowsAffected()
|
return err
|
||||||
if rows == 0 {
|
|
||||||
return fmt.Errorf("failed to create table with %s", sql)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err = result.RowsAffected()
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "memos",
|
"name": "memos",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "tsc && vite build",
|
"build": "tsc && vite build",
|
||||||
|
|
Loading…
Add table
Reference in a new issue