Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.

Merge user & profile tables #1505

Merged
merged 12 commits into from
Jun 15, 2020
Merged

Merge user & profile tables #1505

merged 12 commits into from
Jun 15, 2020

Conversation

kiootic
Copy link
Contributor

@kiootic kiootic commented Jun 10, 2020

ref #1477
ref #1497

@kiootic kiootic requested a review from louischan-oursky June 10, 2020 08:16
@kiootic kiootic marked this pull request as ready for review June 10, 2020 11:19
func cmdStatus(args []string) {
db := openDB()

migrate.SetTable("migrations")
Copy link
Contributor

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,
Copy link
Contributor

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?

@@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary?

Copy link
Contributor Author

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 -_-

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary?

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary?

@@ -1,6 +1,6 @@
package db

// MockTxContext implements and record db.TxContext methods
// MockTxContext implements and record migrate.TxContext methods
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@louischan-oursky louischan-oursky merged commit 6fbb8d8 into SkygearIO:independence-refactor Jun 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants