mirror of
				https://github.com/usememos/memos.git
				synced 2025-11-04 12:27:35 +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
 | 
			
		||||
        uses: docker/login-action@v1
 | 
			
		||||
        with:
 | 
			
		||||
          username: ${{ secrets.DOCKER_NEOSMEMO_USERNAME }}
 | 
			
		||||
          username: neosmemo
 | 
			
		||||
          password: ${{ secrets.DOCKER_NEOSMEMO_TOKEN }}
 | 
			
		||||
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
| 
						 | 
				
			
			@ -35,4 +35,4 @@ jobs:
 | 
			
		|||
          context: ./
 | 
			
		||||
          file: ./Dockerfile
 | 
			
		||||
          push: true
 | 
			
		||||
          tags: ${{ secrets.DOCKER_NEOSMEMO_USERNAME }}/memos:${{ env.VERSION }}
 | 
			
		||||
          tags: neosmemo/memos:${{ env.VERSION }}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@
 | 
			
		|||
## ⚓️ Deploy with 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.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
package common
 | 
			
		||||
 | 
			
		||||
// 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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (db *DB) migrate() error {
 | 
			
		||||
	err := db.compareMigrationHistory()
 | 
			
		||||
	err = db.compareMigrationHistory()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		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"))
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
| 
						 | 
				
			
			@ -137,12 +137,12 @@ func (db *DB) executeFile(FS embed.FS, name string) error {
 | 
			
		|||
 | 
			
		||||
// compareMigrationHistory compares migration history data
 | 
			
		||||
func (db *DB) compareMigrationHistory() error {
 | 
			
		||||
	table, err := findTable(db, "migration_history")
 | 
			
		||||
	table, err := findTable(db.Db, "migration_history")
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if table == nil {
 | 
			
		||||
		if err := createTable(db, `
 | 
			
		||||
		if err := createTable(db.Db, `
 | 
			
		||||
		CREATE TABLE migration_history (
 | 
			
		||||
			version TEXT NOT NULL PRIMARY KEY,
 | 
			
		||||
			created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now'))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
package db
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"database/sql"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -10,13 +10,13 @@ type Table struct {
 | 
			
		|||
	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 = append(where, "type = ?"), append(args, "table")
 | 
			
		||||
	where, args = append(where, "name = ?"), append(args, tableName)
 | 
			
		||||
 | 
			
		||||
	rows, err := db.Db.Query(`
 | 
			
		||||
	rows, err := db.Query(`
 | 
			
		||||
		SELECT
 | 
			
		||||
			tbl_name,
 | 
			
		||||
			sql
 | 
			
		||||
| 
						 | 
				
			
			@ -53,13 +53,13 @@ func findTable(db *DB, tableName string) (*Table, error) {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func createTable(db *DB, sql string) error {
 | 
			
		||||
	result, err := db.Db.Exec(sql)
 | 
			
		||||
 | 
			
		||||
	rows, _ := result.RowsAffected()
 | 
			
		||||
	if rows == 0 {
 | 
			
		||||
		return fmt.Errorf("failed to create table with %s", sql)
 | 
			
		||||
func createTable(db *sql.DB, sql string) error {
 | 
			
		||||
	result, err := db.Exec(sql)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	_, err = result.RowsAffected()
 | 
			
		||||
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
{
 | 
			
		||||
  "name": "memos",
 | 
			
		||||
  "version": "0.1.2",
 | 
			
		||||
  "version": "0.1.3",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "dev": "vite",
 | 
			
		||||
    "build": "tsc && vite build",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue