-
Notifications
You must be signed in to change notification settings - Fork 84
Merge user & profile tables #1505
Merge user & profile tables #1505
Conversation
migrate/migrate.go
Outdated
func cmdStatus(args []string) { | ||
db := openDB() | ||
|
||
migrate.SetTable("migrations") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_auth_migration
? Make it a constant instead.
var commands = map[string]func(args []string){ | ||
"new": cmdNew, | ||
"up": cmdUp, | ||
"status": cmdStatus, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we implement down
as well?
pkg/core/config/tenant_test.go
Outdated
@@ -113,7 +113,7 @@ func makeFullTenantConfig() TenantConfiguration { | |||
AppName: "myapp", | |||
AppID: "66EAFE32-BF5C-4878-8FC8-DD0EEA440981", | |||
DatabaseConfig: &DatabaseConfiguration{ | |||
DatabaseURL: "postgres://user:password@localhost:5432/db?sslmode=disable", | |||
DatabaseURL: "postgres://user:password@localhost:5432/migrate?sslmode=disable", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDE auto-refactor is too powerful -_-
pkg/core/db/context.go
Outdated
@@ -17,7 +17,7 @@ var ( | |||
keyContainer = contextKey("container") | |||
) | |||
|
|||
// Context provides db with the interface for retrieving an interface to execute sql | |||
// Context provides migrate with the interface for retrieving an interface to execute sql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary?
pkg/core/db/context.go
Outdated
@@ -95,7 +95,7 @@ func InitDBContext(ctx context.Context, pool Pool) context.Context { | |||
return context.WithValue(ctx, keyContainer, container) | |||
} | |||
|
|||
// InitRequestDBContext initialize db context for the request | |||
// InitRequestDBContext initialize migrate context for the request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary?
pkg/core/db/mock_context.go
Outdated
@@ -1,6 +1,6 @@ | |||
package db | |||
|
|||
// MockTxContext implements and record db.TxContext methods | |||
// MockTxContext implements and record migrate.TxContext methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary?
created_at timestamp without time zone NOT NULL, | ||
updated_at timestamp without time zone NOT NULL, | ||
scopes jsonb NOT NULL, | ||
UNIQUE (app_id, user_id, client_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly create EACH unique index with CREATE UNIQUE INDEX
so that the name is deterministic.
We should introduce the down migration as well. In the down migration we can drop the unique index first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to drop the unique indexes explicitly, since dropping the table would drop them too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add down
command first and we can verify whether unique indexes are dropped along with the tables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried and indexes are dropped along with the tables.
app_id text NOT NULL, | ||
user_id text NOT NULL REFERENCES _auth_user (id), | ||
password text NOT NULL, | ||
logged_at timestamp without time zone NOT NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename logged_at
to created_at
.
@@ -135,7 +133,6 @@ func main() { | |||
ReservedNameChecker: reservedNameChecker, | |||
} | |||
|
|||
task.AttachVerifyCodeSendTask(asyncTaskExecutor, authDependency) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the configuration as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I planned to cleanup & refactor the configuration (config/tenant.go) as a separate task.
ref #1477
ref #1497