Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
evm-store
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanli
evm-store
Commits
0eb0a727
Commit
0eb0a727
authored
Jul 21, 2021
by
wanli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎈
perf(): 优化启动脚本以及迁移工具
parent
9efe94e6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
130 additions
and
13 deletions
+130
-13
backend/run.sh
backend/run.sh
+9
-1
backend/start.sh
backend/start.sh
+9
-1
tools/database_migration.go
tools/database_migration.go
+92
-0
tools/database_migration.py
tools/database_migration.py
+13
-11
tools/go.mod
tools/go.mod
+5
-0
tools/go.sum
tools/go.sum
+2
-0
No files found.
backend/run.sh
View file @
0eb0a727
#!/usr/bin/env bash
#!/usr/bin/env bash
###
# @Author: your name
# @Date: 2021-07-15 09:33:39
# @LastEditTime: 2021-07-21 14:25:03
# @LastEditors: Please set LastEditors
# @Description: In User Settings Edit
# @FilePath: \evm-store\backend\run.sh
###
# 获取当前路径
# 获取当前路径
Cur_Dir
=
$(
pwd
)
Cur_Dir
=
$(
pwd
)
...
@@ -26,4 +34,4 @@ supervisorctl start evm_store
...
@@ -26,4 +34,4 @@ supervisorctl start evm_store
Cur_Dir
=
$(
pwd
)
Cur_Dir
=
$(
pwd
)
source
venv/bin/activate
source
venv/bin/activate
nohup
${
Cur_Dir
}
/venv/bin/python3
${
Cur_Dir
}
/start.py
>
run
oob
.log 2>&1 &
nohup
${
Cur_Dir
}
/venv/bin/python3
${
Cur_Dir
}
/start.py
>
run
ning
.log 2>&1 &
backend/start.sh
View file @
0eb0a727
#!/usr/bin/env bash
#!/usr/bin/env bash
###
# @Author: your name
# @Date: 2021-07-15 09:33:39
# @LastEditTime: 2021-07-21 14:25:13
# @LastEditors: your name
# @Description: In User Settings Edit
# @FilePath: \evm-store\backend\start.sh
###
Cur_Dir
=
$(
pwd
)
Cur_Dir
=
$(
pwd
)
source
venv/bin/activate
source
venv/bin/activate
nohup
${
Cur_Dir
}
/venv/bin/python3
${
Cur_Dir
}
/start.py
>
run
oob
.log 2>&1 &
nohup
${
Cur_Dir
}
/venv/bin/python3
${
Cur_Dir
}
/start.py
>
run
ning
.log 2>&1 &
tools/database_migration.go
0 → 100644
View file @
0eb0a727
/*
* @Author: your name
* @Date: 2021-07-21 13:02:17
* @LastEditTime: 2021-07-21 13:09:34
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \evm-store\tools\database_migration.go
*/
package
main
import
(
"database/sql"
"fmt"
_
"github.com/mattn/go-sqlite3"
)
func
main
()
{
fmt
.
Println
(
"打开数据"
)
db
,
err
:=
sql
.
Open
(
"sqlite3"
,
"./evue_store.db"
)
checkErr
(
err
)
fmt
.
Println
(
"生成数据表"
)
sql_table
:=
`
CREATE TABLE IF NOT EXISTS "userinfo" (
"uid" INTEGER PRIMARY KEY AUTOINCREMENT,
"username" VARCHAR(64) NULL,
"departname" VARCHAR(64) NULL,
"created" TIMESTAMP default (datetime('now', 'localtime'))
);
CREATE TABLE IF NOT EXISTS "userdeatail" (
"uid" INT(10) NULL,
"intro" TEXT NULL,
"profile" TEXT NULL,
PRIMARY KEY (uid)
);
`
db
.
Exec
(
sql_table
)
//插入数据
fmt
.
Print
(
"插入数据, ID="
)
stmt
,
err
:=
db
.
Prepare
(
"INSERT INTO userinfo(username, departname) values(?, ?)"
)
checkErr
(
err
)
res
,
err
:=
stmt
.
Exec
(
"astaxie"
,
"研发部门"
)
checkErr
(
err
)
id
,
err
:=
res
.
LastInsertId
()
checkErr
(
err
)
fmt
.
Println
(
id
)
//更新数据
fmt
.
Print
(
"更新数据 "
)
stmt
,
err
=
db
.
Prepare
(
"update userinfo set username=? where uid=?"
)
checkErr
(
err
)
res
,
err
=
stmt
.
Exec
(
"astaxieupdate"
,
id
)
checkErr
(
err
)
affect
,
err
:=
res
.
RowsAffected
()
checkErr
(
err
)
fmt
.
Println
(
affect
)
//查询数据
fmt
.
Println
(
"查询数据"
)
rows
,
err
:=
db
.
Query
(
"SELECT * FROM userinfo"
)
checkErr
(
err
)
for
rows
.
Next
()
{
var
uid
int
var
username
string
var
department
string
var
created
string
err
=
rows
.
Scan
(
&
uid
,
&
username
,
&
department
,
&
created
)
checkErr
(
err
)
fmt
.
Println
(
uid
,
username
,
department
,
created
)
}
/*
//删除数据
fmt.Println("删除数据")
stmt, err = db.Prepare("delete from userinfo where uid=?")
checkErr(err)
res, err = stmt.Exec(id)
checkErr(err)
affect, err = res.RowsAffected()
checkErr(err)
fmt.Println(affect)
*/
db
.
Close
()
}
func
checkErr
(
err
error
)
{
if
err
!=
nil
{
panic
(
err
)
}
}
tools/database_migration.py
View file @
0eb0a727
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
'''
'''
Author: your name
Author: your name
Date: 2021-07-20 19:04:27
Date: 2021-07-20 19:04:27
LastEditTime: 2021-07-21 1
0:05:11
LastEditTime: 2021-07-21 1
3:34:32
LastEditors: Please set LastEditors
LastEditors: Please set LastEditors
Description: In User Settings Edit
Description: In User Settings Edit
FilePath:
\
evm-store
\t
ools
\
database_migration.py
FilePath:
\
evm-store
\t
ools
\
database_migration.py
...
@@ -33,6 +33,8 @@ with open("database_migration.sql", "w+") as fd:
...
@@ -33,6 +33,8 @@ with open("database_migration.sql", "w+") as fd:
]
]
sqls
=
[
sqls
=
[
"update evm_store_apps set create_by = {a} where create_by = {b};"
,
"update evm_store_apps set update_by = {a} where update_by = {b};"
,
"update evm_store_annex set create_by = {a} where create_by = {b};"
,
"update evm_store_annex set create_by = {a} where create_by = {b};"
,
"update evm_store_annex set update_by = {a} where update_by = {b};"
,
"update evm_store_annex set update_by = {a} where update_by = {b};"
,
"update evm_store_app_logs set create_by = {a} where create_by = {b};"
,
"update evm_store_app_logs set create_by = {a} where create_by = {b};"
,
...
@@ -51,7 +53,7 @@ with open("database_migration.sql", "w+") as fd:
...
@@ -51,7 +53,7 @@ with open("database_migration.sql", "w+") as fd:
# 先插入user表
# 先插入user表
source_cur
.
execute
(
'SELECT account, username, password, email, phone, create_at, create_by, update_at, update_by FROM evm_store_user'
)
source_cur
.
execute
(
'SELECT account, username, password, email, phone, create_at, create_by, update_at, update_by FROM evm_store_user'
)
sql
=
"insert into evm_user (id, uuid, account, username, password, email, phone, create_at, create_by, update_at, update_by, is_delete
) values ({a}, '{b}', '{c}', '{d}', '{e}', '{f}', '{g}', '{h}', {i}, '{j}', {k}
, 0);"
sql
=
"insert into evm_user (id, uuid, account, username, password, email, phone, create_at, create_by, update_at, update_by, is_delete
, role) values ({a}, '{b}', '{c}', '{d}', '{e}', '{f}', '{g}', '{h}', {i}, '{j}', {k}, 0
, 0);"
res
=
source_cur
.
fetchall
()
res
=
source_cur
.
fetchall
()
i
=
0
i
=
0
for
line
in
res
:
for
line
in
res
:
...
@@ -65,9 +67,9 @@ with open("database_migration.sql", "w+") as fd:
...
@@ -65,9 +67,9 @@ with open("database_migration.sql", "w+") as fd:
# login logs
# login logs
source_cur
.
execute
(
'SELECT id, username, ip, address, create_at, create_by, remarks FROM evm_store_login_logs'
)
source_cur
.
execute
(
'SELECT id, username, ip, address, create_at, create_by, remarks FROM evm_store_login_logs'
)
res
=
source_cur
.
fetchall
()
res
=
source_cur
.
fetchall
()
sql
=
"insert into evm_login (
id, uuid, user, login_at, user_agent, ip, geo_location, operator, create_at, create_by, update_at, update_by, is_delete) values ({a},
'{b}', {c}, '{d}', '{e}', '{f}', '{g}', '{h}', '{i}', {j}, '{k}', {l}, 0);"
sql
=
"insert into evm_login (
uuid, user, login_at, user_agent, ip, geo_location, operator, create_at, create_by, update_at, update_by, is_delete) values (
'{b}', {c}, '{d}', '{e}', '{f}', '{g}', '{h}', '{i}', {j}, '{k}', {l}, 0);"
for
line
in
res
:
for
line
in
res
:
sql_str
=
sql
.
format
(
a
=
line
[
0
],
b
=
uuid
.
uuid1
()
.
hex
,
c
=
line
[
5
],
d
=
line
[
6
],
e
=
""
,
f
=
line
[
2
],
g
=
line
[
3
],
h
=
""
,
i
=
line
[
4
],
j
=
line
[
5
],
k
=
line
[
4
],
l
=
line
[
5
])
sql_str
=
sql
.
format
(
b
=
uuid
.
uuid1
()
.
hex
,
c
=
line
[
5
],
d
=
line
[
6
],
e
=
""
,
f
=
line
[
2
],
g
=
line
[
3
],
h
=
""
,
i
=
line
[
4
],
j
=
line
[
5
],
k
=
line
[
4
],
l
=
line
[
5
])
# target_cur.execute(sql_str)
# target_cur.execute(sql_str)
fd
.
write
(
sql_str
+
"
\n
"
)
fd
.
write
(
sql_str
+
"
\n
"
)
target_conn
.
commit
()
target_conn
.
commit
()
...
@@ -78,12 +80,12 @@ with open("database_migration.sql", "w+") as fd:
...
@@ -78,12 +80,12 @@ with open("database_migration.sql", "w+") as fd:
res
=
source_cur
.
fetchall
()
res
=
source_cur
.
fetchall
()
for
line
in
res
:
for
line
in
res
:
sql_str
=
string
=
"update evm_store_apps set app_url = '{u}' where id = {a}"
.
format
(
u
=
line
[
1
],
a
=
line
[
0
])
sql_str
=
string
=
"update evm_store_apps set app_url = '{u}' where id = {a}"
.
format
(
u
=
line
[
1
],
a
=
line
[
0
])
# target
_cur.execute(sql_str)
source
_cur
.
execute
(
sql_str
)
fd
.
write
(
sql_str
+
"
\n
"
)
#
fd.write(sql_str + "\n")
target_conn
.
commit
()
target_conn
.
commit
()
# annex
# annex
source_cur
.
execute
(
'SELECT id, uuid, app, title, path, size, create_
by, create_at, update_by, update_at
, is_delete FROM evm_store_annex'
)
source_cur
.
execute
(
'SELECT id, uuid, app, title, path, size, create_
at, create_by, update_at, update_by
, is_delete FROM evm_store_annex'
)
res
=
source_cur
.
fetchall
()
res
=
source_cur
.
fetchall
()
sql
=
"insert into evm_annex (id, uuid, app, title, path, size, create_at, create_by, update_at, update_by, is_delete) values ({a}, '{b}', {c}, '{d}', '{e}', {f}, '{g}', {h}, '{i}', {j}, 0);"
sql
=
"insert into evm_annex (id, uuid, app, title, path, size, create_at, create_by, update_at, update_by, is_delete) values ({a}, '{b}', {c}, '{d}', '{e}', {f}, '{g}', {h}, '{i}', {j}, 0);"
for
line
in
res
:
for
line
in
res
:
...
@@ -118,7 +120,7 @@ with open("database_migration.sql", "w+") as fd:
...
@@ -118,7 +120,7 @@ with open("database_migration.sql", "w+") as fd:
res
=
source_cur
.
fetchall
()
res
=
source_cur
.
fetchall
()
sql
=
"insert into evm_package (id, uuid, app_name, app_path, app_version, app_info, create_at, create_by, update_at, update_by, is_delete, source) values ({a}, '{b}', '{c}', '{d}', '{e}', '{f}', '{g}', {h}, '{i}', {j}, {k}, {l});"
sql
=
"insert into evm_package (id, uuid, app_name, app_path, app_version, app_info, create_at, create_by, update_at, update_by, is_delete, source) values ({a}, '{b}', '{c}', '{d}', '{e}', '{f}', '{g}', {h}, '{i}', {j}, {k}, {l});"
for
line
in
res
:
for
line
in
res
:
s
=
1
if
line
[
3
]
.
find
(
"evueapps"
)
>
-
1
else
0
s
=
1
if
line
[
5
]
and
isinstance
(
line
[
5
],
str
)
and
line
[
5
]
.
find
(
"evueapps"
)
>
-
1
else
0
sql_str
=
sql
.
format
(
a
=
line
[
0
],
b
=
uuid
.
uuid1
()
.
hex
,
c
=
line
[
2
],
d
=
line
[
3
],
e
=
line
[
4
],
f
=
line
[
5
],
g
=
line
[
6
],
h
=
line
[
7
],
i
=
line
[
6
],
j
=
line
[
7
],
k
=
0
,
l
=
s
)
sql_str
=
sql
.
format
(
a
=
line
[
0
],
b
=
uuid
.
uuid1
()
.
hex
,
c
=
line
[
2
],
d
=
line
[
3
],
e
=
line
[
4
],
f
=
line
[
5
],
g
=
line
[
6
],
h
=
line
[
7
],
i
=
line
[
6
],
j
=
line
[
7
],
k
=
0
,
l
=
s
)
# target_cur.execute(sql_str)
# target_cur.execute(sql_str)
fd
.
write
(
sql_str
+
"
\n
"
)
fd
.
write
(
sql_str
+
"
\n
"
)
...
@@ -132,18 +134,18 @@ with open("database_migration.sql", "w+") as fd:
...
@@ -132,18 +134,18 @@ with open("database_migration.sql", "w+") as fd:
for
line
in
res
:
for
line
in
res
:
sql_str
=
"select id, uuid, app_path from evm_store_app_logs where app_path = '{}'"
.
format
(
line
[
3
])
sql_str
=
"select id, uuid, app_path from evm_store_app_logs where app_path = '{}'"
.
format
(
line
[
3
])
source_cur
.
execute
(
sql_str
)
source_cur
.
execute
(
sql_str
)
print
(
"
%%%%%%%%%%%%%%
"
,
sql_str
)
tmp
=
source_cur
.
fetchone
()
tmp
=
source_cur
.
fetchone
()
print
(
"=======>"
,
line
[
0
])
if
tmp
:
if
tmp
:
continue
continue
print
(
"===========>"
,
line
)
print
(
"===========>"
,
line
)
sql_str
=
string
=
"select app_name, app_version from evm_store_apps where id == {id}"
.
format
(
id
=
line
[
2
])
sql_str
=
"select app_name, app_version from evm_store_apps where id == {id}"
.
format
(
id
=
line
[
2
])
source_cur
.
execute
(
sql_str
)
source_cur
.
execute
(
sql_str
)
app
=
source_cur
.
fetchone
()
app
=
source_cur
.
fetchone
()
print
(
"app:"
,
app
)
print
(
"app:"
,
app
)
if
app
:
if
app
:
s
=
1
if
line
[
5
]
and
line
[
5
]
.
find
(
"evueapps"
)
>
-
1
else
0
s
=
1
if
line
[
5
]
and
isinstance
(
line
[
5
],
str
)
and
line
[
5
]
.
find
(
"evueapps"
)
>
-
1
else
0
sql_str
=
sql
.
format
(
a
=
line
[
0
],
b
=
uuid
.
uuid1
()
.
hex
,
c
=
app
[
0
],
d
=
line
[
3
],
e
=
app
[
1
],
f
=
line
[
4
],
g
=
s
,
h
=
line
[
6
],
i
=
line
[
7
],
j
=
line
[
8
],
k
=
line
[
9
],
l
=
line
[
10
])
sql_str
=
sql
.
format
(
a
=
line
[
0
],
b
=
uuid
.
uuid1
()
.
hex
,
c
=
app
[
0
],
d
=
line
[
3
],
e
=
app
[
1
],
f
=
line
[
4
],
g
=
s
,
h
=
line
[
6
],
i
=
line
[
7
],
j
=
line
[
8
],
k
=
line
[
9
],
l
=
line
[
10
])
# target_cur.execute(sql_str)
# target_cur.execute(sql_str)
fd
.
write
(
sql_str
+
"
\n
"
)
fd
.
write
(
sql_str
+
"
\n
"
)
...
...
tools/go.mod
0 → 100644
View file @
0eb0a727
module tool
go 1.16
require github.com/mattn/go-sqlite3 v1.14.8
tools/go.sum
0 → 100644
View file @
0eb0a727
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment