-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from salvo-rs/db
add rbatis template
- Loading branch information
Showing
14 changed files
with
421 additions
and
140 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
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 |
---|---|---|
|
@@ -25,7 +25,22 @@ database_url="file:data/test.db" | |
{{#if is_mysql}} | ||
database_url="mysql://root:[email protected]:3306/diesel_example" | ||
{{/if}} | ||
{{/if}}{{/if}} | ||
{{/if}} | ||
{{#if is_rbatis}} | ||
{{#if is_postgres}} | ||
database_url=postgres://liufankai:1@localhost/rbatis_example | ||
{{/if}} | ||
{{#if is_sqlite}} | ||
database_url="data/rbatis_sqlite.db" | ||
{{/if}} | ||
{{#if is_mysql}} | ||
database_url="mysql://root:[email protected]:3306/rbatis_example" | ||
{{/if}} | ||
{{#if is_mssql}} | ||
database_url="mssql://SA:TestPass!123456@localhost:1433/rbatis_example" | ||
{{/if}} | ||
{{/if}} | ||
{{/if}} | ||
[jwt] | ||
jwt_secret = "secret" | ||
jwt_exp = 6000 | ||
|
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,15 @@ | ||
CREATE TABLE IF NOT EXISTS users | ||
( | ||
id TEXT PRIMARY KEY NOT NULL, | ||
username VARCHAR(255) NOT NULL UNIQUE, | ||
password VARCHAR(511) NOT NULL | ||
); | ||
BEGIN; | ||
MERGE INTO users AS target | ||
USING (VALUES ('cdd0e080-5bb1-4442-b6f7-2ba60dbd0555', 'zhangsan', '$argon2id$v=19$m=19456,t=2,p=1$rcosL5pOPdA2c7i4ZuLA4Q$s0JGh78UzMmu1qZMpVUA3b8kWYLXcZhw7uBfwhYDJ4A')) | ||
AS source (id, username, password) | ||
ON (target.id = source.id) | ||
WHEN NOT MATCHED THEN | ||
INSERT (id, username, password) | ||
VALUES (source.id, source.username, source.password); | ||
COMMIT; |
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,9 @@ | ||
CREATE TABLE IF NOT EXISTS users | ||
( | ||
id TEXT PRIMARY KEY NOT NULL, | ||
username VARCHAR(255) NOT NULL UNIQUE, | ||
password VARCHAR(511) NOT NULL | ||
); | ||
BEGIN; | ||
INSERT IGNORE INTO "users" ("id", "username", "password") VALUES ('cdd0e080-5bb1-4442-b6f7-2ba60dbd0555', 'zhangsan', '$argon2id$v=19$m=19456,t=2,p=1$rcosL5pOPdA2c7i4ZuLA4Q$s0JGh78UzMmu1qZMpVUA3b8kWYLXcZhw7uBfwhYDJ4A'); | ||
COMMIT; |
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,9 @@ | ||
CREATE TABLE IF NOT EXISTS users | ||
( | ||
id TEXT PRIMARY KEY NOT NULL, | ||
username VARCHAR(255) NOT NULL UNIQUE, | ||
password VARCHAR(511) NOT NULL | ||
); | ||
BEGIN; | ||
INSERT INTO "users" ("id", "username", "password") VALUES ('cdd0e080-5bb1-4442-b6f7-2ba60dbd0555', 'zhangsan', '$argon2id$v=19$m=19456,t=2,p=1$rcosL5pOPdA2c7i4ZuLA4Q$s0JGh78UzMmu1qZMpVUA3b8kWYLXcZhw7uBfwhYDJ4A') ON CONFLICT DO NOTHING; | ||
COMMIT; |
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,9 @@ | ||
CREATE TABLE IF NOT EXISTS users | ||
( | ||
id TEXT PRIMARY KEY NOT NULL, | ||
username VARCHAR(255) NOT NULL UNIQUE, | ||
password VARCHAR(511) NOT NULL | ||
); | ||
BEGIN; | ||
INSERT OR IGNORE INTO "users" ("id", "username", "password") VALUES ('cdd0e080-5bb1-4442-b6f7-2ba60dbd0555', 'zhangsan', '$argon2id$v=19$m=19456,t=2,p=1$rcosL5pOPdA2c7i4ZuLA4Q$s0JGh78UzMmu1qZMpVUA3b8kWYLXcZhw7uBfwhYDJ4A'); | ||
COMMIT; |
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 |
---|---|---|
|
@@ -8,3 +8,6 @@ pub mod prelude; | |
|
||
pub mod user; | ||
{{/if}} | ||
{{#if is_rbatis}} | ||
pub mod user; | ||
{{/if}} |
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
Oops, something went wrong.