-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(datahub-upgrade): Add support for Postgres migration #2740
Changes from 4 commits
daff3cd
61a3dbb
383522a
8fe201f
d57fe14
a1307b1
4cc40ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,9 +7,16 @@ | |||||
import io.ebean.EbeanServer; | ||||||
import java.util.function.Function; | ||||||
|
||||||
// Do we need SQL-tech specific migration paths? | ||||||
public class CreateAspectTableStep implements UpgradeStep { | ||||||
|
||||||
private static final String DB_TYPE_ARG = "dbType"; | ||||||
|
||||||
enum DbType { | ||||||
MY_SQL, | ||||||
POSTGRES, | ||||||
MARIA | ||||||
} | ||||||
|
||||||
private final EbeanServer _server; | ||||||
|
||||||
public CreateAspectTableStep(final EbeanServer server) { | ||||||
|
@@ -29,18 +36,45 @@ public int retryCount() { | |||||
@Override | ||||||
public Function<UpgradeContext, UpgradeStepResult> executable() { | ||||||
return (context) -> { | ||||||
|
||||||
DbType targetDbType = context.parsedArgs().containsKey(DB_TYPE_ARG) | ||||||
? DbType.valueOf(context.parsedArgs().get(DB_TYPE_ARG).get()) | ||||||
: DbType.MY_SQL; | ||||||
|
||||||
String sqlUpdateStr; | ||||||
|
||||||
switch (targetDbType) { | ||||||
case POSTGRES: | ||||||
sqlUpdateStr = "CREATE TABLE IF NOT EXISTS metadata_aspect_v2 (\n" | ||||||
+ " urn varchar(500) not null,\n" | ||||||
+ " aspect varchar(200) not null,\n" | ||||||
+ " version bigint(20) not null,\n" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After some testing, it seems that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you're right. Just also verified. Thanks! |
||||||
+ " metadata text not null,\n" | ||||||
+ " systemmetadata text,\n" | ||||||
+ " createdon timestamp not null,\n" | ||||||
+ " createdby varchar(255) not null,\n" | ||||||
+ " createdfor varchar(255),\n" | ||||||
+ " constraint pk_metadata_aspect primary key (urn,aspect,version)\n" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
+ ")"; | ||||||
break; | ||||||
default: | ||||||
// both mysql and maria | ||||||
sqlUpdateStr = "CREATE TABLE IF NOT EXISTS metadata_aspect_v2 (\n" | ||||||
+ " urn varchar(500) not null,\n" | ||||||
+ " aspect varchar(200) not null,\n" | ||||||
+ " version bigint(20) not null,\n" | ||||||
+ " metadata longtext not null,\n" | ||||||
+ " systemmetadata longtext,\n" | ||||||
+ " createdon datetime(6) not null,\n" | ||||||
+ " createdby varchar(255) not null,\n" | ||||||
+ " createdfor varchar(255),\n" | ||||||
+ " constraint pk_metadata_aspect primary key (urn,aspect,version)\n" | ||||||
+ ")"; | ||||||
break; | ||||||
} | ||||||
|
||||||
try { | ||||||
_server.execute(_server.createSqlUpdate("CREATE TABLE IF NOT EXISTS metadata_aspect_v2 (\n" | ||||||
+ " urn varchar(500) not null,\n" | ||||||
+ " aspect varchar(200) not null,\n" | ||||||
+ " version bigint(20) not null,\n" | ||||||
+ " metadata longtext not null,\n" | ||||||
+ " systemmetadata longtext,\n" | ||||||
+ " createdon datetime(6) not null,\n" | ||||||
+ " createdby varchar(255) not null,\n" | ||||||
+ " createdfor varchar(255),\n" | ||||||
+ " constraint pk_metadata_aspect primary key (urn,aspect,version)\n" | ||||||
+ ")")); | ||||||
_server.execute(_server.createSqlUpdate(sqlUpdateStr)); | ||||||
} catch (Exception e) { | ||||||
context.report().addLine(String.format("Failed to create table metadata_aspect_v2: %s", e.toString())); | ||||||
return new DefaultUpgradeStepResult( | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ As of today, there are 2 supported upgrades: | |
to metadata_aspect_v2 table. Arguments: | ||
- *batchSize* (Optional): The number of rows to migrate at a time. Defaults to 1000. | ||
- *batchDelayMs* (Optional): The number of milliseconds of delay between migrated batches. Used for rate limiting. Defaults to 250. | ||
- *dbType* (optional): The target DB type. Valid values are `MY_SQL`, `MARIA`, `POSTGRES`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's optional, which is the default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
|
||
2. **NoCodeDataMigrationCleanup**: Cleanses graph index, search index, and key-value store of legacy DataHub data (metadata_aspect table) once | ||
the No Code Data Migration has completed successfully. No arguments. | ||
|
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.
Heh, I think we got our answer 😅
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.
lol. yes!