Skip to content

Commit

Permalink
Merge pull request #920 from traPtitech/chores
Browse files Browse the repository at this point in the history
Chores
  • Loading branch information
wtks authored May 21, 2020
2 parents 79828c1 + de523ff commit bf082b4
Show file tree
Hide file tree
Showing 64 changed files with 1,960 additions and 2,030 deletions.
3 changes: 0 additions & 3 deletions .tbls.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,6 @@ comments:
token: セッショントークン
reference_id: 参照ID
user_id: セッションがログインしているユーザーUUID
last_access: 最終アクセス日時
last_ip: 最終アクセスIPアドレス
last_user_agent: 最終アクセスUserAgent
data: セッションデータ(gobバイナリ)
created: 生成日時
- table: oauth2_authorizes
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ db-gen-docs:
@if [ -d "./docs/dbschema" ]; then \
rm -r ./docs/dbschema; \
fi
go run main.go migrate --reset --port $(TEST_DB_PORT)
TRAQ_MARIADB_PORT=$(TEST_DB_PORT) go run main.go migrate --reset
TBLS_DSN="mysql://root:[email protected]:$(TEST_DB_PORT)/traq" tbls doc

.PHONY: db-diff-docs
db-diff-docs:
go run main.go migrate --reset --port $(TEST_DB_PORT)
TRAQ_MARIADB_PORT=$(TEST_DB_PORT) go run main.go migrate --reset
TBLS_DSN="mysql://root:[email protected]:$(TEST_DB_PORT)/traq" tbls diff

.PHONY: db-lint
db-lint:
go run main.go migrate --reset --port $(TEST_DB_PORT)
TRAQ_MARIADB_PORT=$(TEST_DB_PORT) go run main.go migrate --reset
TBLS_DSN="mysql://root:[email protected]:$(TEST_DB_PORT)/traq" tbls lint

.PHONY: goreleaser-snapshot
Expand Down
12 changes: 0 additions & 12 deletions cmd/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ func fileCommand() *cobra.Command {
filePruneCommand(),
)

flags := cmd.PersistentFlags()
flags.String("host", "", "database host")
bindPFlag(flags, "mariadb.host", "host")
flags.Int("port", 0, "database port")
bindPFlag(flags, "mariadb.port", "port")
flags.String("name", "", "database name")
bindPFlag(flags, "mariadb.database", "name")
flags.String("user", "", "database user")
bindPFlag(flags, "mariadb.username", "user")
flags.String("pass", "", "database password")
bindPFlag(flags, "mariadb.password", "pass")

return &cmd
}

Expand Down
10 changes: 0 additions & 10 deletions cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@ func migrateCommand() *cobra.Command {
}

flags := cmd.Flags()
flags.String("host", "", "database host")
bindPFlag(flags, "mariadb.host", "host")
flags.Int("port", 0, "database port")
bindPFlag(flags, "mariadb.port", "port")
flags.String("name", "", "database name")
bindPFlag(flags, "mariadb.database", "name")
flags.String("user", "", "database user")
bindPFlag(flags, "mariadb.username", "user")
flags.String("pass", "", "database password")
bindPFlag(flags, "mariadb.password", "pass")
flags.BoolVar(&dropDB, "reset", false, "whether to truncate database (drop all tables)")

return &cmd
Expand Down
12 changes: 0 additions & 12 deletions cmd/migrate_v2_to_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ func migrateV2ToV3Command() *cobra.Command {
}

flags := cmd.Flags()
flags.String("host", "", "database host")
bindPFlag(flags, "mariadb.host", "host")
flags.Int("port", 0, "database port")
bindPFlag(flags, "mariadb.port", "port")
flags.String("name", "", "database name")
bindPFlag(flags, "mariadb.database", "name")
flags.String("user", "", "database user")
bindPFlag(flags, "mariadb.username", "user")
flags.String("pass", "", "database password")
bindPFlag(flags, "mariadb.password", "pass")
flags.String("origin", "", "traQ origin")
bindPFlag(flags, "origin", "origin")
flags.BoolVar(&dryRun, "dry-run", false, "dry run")
flags.BoolVar(&skipConvertMessage, "skip-convert-message", false, "skip message converting")
flags.IntVar(&startMessagePage, "start-message-page", 0, "start message page (zero-origin)")
Expand Down
9 changes: 0 additions & 9 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/leandro-lugaresi/hub"
"github.com/spf13/cobra"
"github.com/traPtitech/traQ/repository"
"github.com/traPtitech/traQ/router/sessions"
"github.com/traPtitech/traQ/service"
"github.com/traPtitech/traQ/utils/gormzap"
"github.com/traPtitech/traQ/utils/jwt"
Expand Down Expand Up @@ -98,13 +97,6 @@ func serveCommand() *cobra.Command {
logger.Info("data initialization finished")
}

// SessionStore
sessionStore, err := sessions.NewGORMStore(engine)
if err != nil {
logger.Fatal("failed to setup session store", zap.Error(err))
}
sessions.SetStore(sessionStore)

// JWT for QRCode
if priv := c.JWT.Keys.Private; priv != "" {
privRaw, err := ioutil.ReadFile(priv)
Expand Down Expand Up @@ -141,7 +133,6 @@ func serveCommand() *cobra.Command {
if err := server.Shutdown(ctx); err != nil {
logger.Warn("abnormal shutdown", zap.Error(err))
}
sessions.PurgeCache()
logger.Info("traQ shutdown")
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/dbschema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
| [oauth2_clients](oauth2_clients.md) | 11 | OAuth2クライアントテーブル | BASE TABLE |
| [oauth2_tokens](oauth2_tokens.md) | 11 | OAuth2トークンテーブル | BASE TABLE |
| [pins](pins.md) | 4 | ピンテーブル | BASE TABLE |
| [r_sessions](r_sessions.md) | 8 | traQ API HTTPセッションテーブル | BASE TABLE |
| [r_sessions](r_sessions.md) | 5 | traQ API HTTPセッションテーブル | BASE TABLE |
| [stamp_palettes](stamp_palettes.md) | 7 | スタンプパレットテーブル | BASE TABLE |
| [stamps](stamps.md) | 8 | スタンプテーブル | BASE TABLE |
| [stars](stars.md) | 2 | お気に入りチャンネルテーブル | BASE TABLE |
Expand Down
4 changes: 3 additions & 1 deletion docs/dbschema/channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ CREATE TABLE `channels` (
`updated_at` datetime(6) DEFAULT NULL,
`deleted_at` datetime(6) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name_parent` (`name`,`parent_id`)
UNIQUE KEY `name_parent` (`name`,`parent_id`),
KEY `idx_channel_channels_id_is_public_is_forced` (`id`,`is_public`,`is_forced`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
```

Expand Down Expand Up @@ -56,6 +57,7 @@ CREATE TABLE `channels` (

| Name | Definition |
| ---- | ---------- |
| idx_channel_channels_id_is_public_is_forced | KEY idx_channel_channels_id_is_public_is_forced (id, is_public, is_forced) USING BTREE |
| PRIMARY | PRIMARY KEY (id) USING BTREE |
| name_parent | UNIQUE KEY name_parent (name, parent_id) USING BTREE |

Expand Down
2 changes: 2 additions & 0 deletions docs/dbschema/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CREATE TABLE `messages` (
KEY `idx_messages_created_at` (`created_at`),
KEY `messages_user_id_users_id_foreign` (`user_id`),
KEY `idx_messages_channel_id_deleted_at_created_at` (`channel_id`,`deleted_at`,`created_at`),
KEY `idx_messages_deleted_at_created_at` (`deleted_at`,`created_at`),
CONSTRAINT `messages_channel_id_channels_id_foreign` FOREIGN KEY (`channel_id`) REFERENCES `channels` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `messages_user_id_users_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
Expand Down Expand Up @@ -55,6 +56,7 @@ CREATE TABLE `messages` (
| idx_messages_channel_id | KEY idx_messages_channel_id (channel_id) USING BTREE |
| idx_messages_channel_id_deleted_at_created_at | KEY idx_messages_channel_id_deleted_at_created_at (channel_id, deleted_at, created_at) USING BTREE |
| idx_messages_created_at | KEY idx_messages_created_at (created_at) USING BTREE |
| idx_messages_deleted_at_created_at | KEY idx_messages_deleted_at_created_at (deleted_at, created_at) USING BTREE |
| messages_user_id_users_id_foreign | KEY messages_user_id_users_id_foreign (user_id) USING BTREE |
| PRIMARY | PRIMARY KEY (id) USING BTREE |

Expand Down
6 changes: 0 additions & 6 deletions docs/dbschema/r_sessions.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ CREATE TABLE `r_sessions` (
`token` varchar(50) NOT NULL DEFAULT '',
`reference_id` char(36) DEFAULT NULL,
`user_id` varchar(36) DEFAULT NULL,
`last_access` datetime(6) DEFAULT NULL,
`last_ip` text,
`last_user_agent` text,
`data` longblob,
`created` datetime(6) DEFAULT NULL,
PRIMARY KEY (`token`),
Expand All @@ -32,9 +29,6 @@ CREATE TABLE `r_sessions` (
| token | varchar(50) | | false | | | セッショントークン |
| reference_id | char(36) | | true | | | 参照ID |
| user_id | varchar(36) | | true | | | セッションがログインしているユーザーUUID |
| last_access | datetime(6) | | true | | | 最終アクセス日時 |
| last_ip | text | | true | | | 最終アクセスIPアドレス |
| last_user_agent | text | | true | | | 最終アクセスUserAgent |
| data | longblob | | true | | | セッションデータ(gobバイナリ) |
| created | datetime(6) | | true | | | 生成日時 |

Expand Down
41 changes: 16 additions & 25 deletions docs/dbschema/r_sessions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 20 additions & 29 deletions docs/dbschema/schema.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit bf082b4

Please sign in to comment.