Skip to content
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

feat: move model_v2 and model_migration into separate crates #13058

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ header:
- "**/*.d.ts"
- "src/sqlparser/**/*.rs"
- "java/connector-node/risingwave-source-cdc/src/main/java/com/risingwave/connector/cdc/debezium/internal/*.java"
- "src/meta/src/model_v2/migration/**/*.rs"
- "src/meta/model_v2/migration/**/*.rs"

comment: on-failure
34 changes: 23 additions & 11 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ members = [
"src/java_binding",
"src/jni_core",
"src/meta",
"src/meta/model_v2",
"src/meta/model_v2/migration",
"src/meta/node",
"src/meta/service",
"src/meta/src/model_v2/migration",
"src/object_store",
"src/prost",
"src/prost/helpers",
Expand Down Expand Up @@ -143,6 +144,8 @@ risingwave_hummock_test = { path = "./src/storage/hummock_test" }
risingwave_hummock_trace = { path = "./src/storage/hummock_trace" }
risingwave_meta = { path = "./src/meta" }
risingwave_meta_service = { path = "./src/meta/service" }
risingwave_meta_model_migration = { path = "src/meta/model_v2/migration" }
risingwave_meta_model_v2 = { path = "./src/meta/model_v2" }
risingwave_meta_node = { path = "./src/meta/node" }
risingwave_object_store = { path = "./src/object_store" }
risingwave_pb = { path = "./src/prost" }
Expand Down
3 changes: 2 additions & 1 deletion src/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ hyper = "0.14"
itertools = "0.11"
memcomparable = { version = "0.2" }
mime_guess = "2"
model_migration = { path = "src/model_v2/migration" }
num-integer = "0.1"
num-traits = "0.2"
parking_lot = { version = "0.12", features = ["arc_lock"] }
Expand All @@ -50,6 +49,8 @@ risingwave_common = { workspace = true }
risingwave_common_heap_profiling = { workspace = true }
risingwave_connector = { workspace = true }
risingwave_hummock_sdk = { workspace = true }
risingwave_meta_model_migration = { workspace = true }
risingwave_meta_model_v2 = { workspace = true }
risingwave_object_store = { workspace = true }
risingwave_pb = { workspace = true }
risingwave_rpc_client = { workspace = true }
Expand Down
26 changes: 26 additions & 0 deletions src/meta/model_v2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "risingwave_meta_model_v2"
version = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
keywords = { workspace = true }
license = { workspace = true }
repository = { workspace = true }

[package.metadata.cargo-machete]
ignored = ["workspace-hack"]

[package.metadata.cargo-udeps.ignore]
normal = ["workspace-hack"]

[dependencies]
risingwave_pb = { workspace = true }
sea-orm = { version = "0.12.0", features = [
"sqlx-mysql",
"sqlx-postgres",
"sqlx-sqlite",
"runtime-tokio-native-tls",
"macros",
] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
22 changes: 22 additions & 0 deletions src/meta/model_v2/migration/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "risingwave_meta_model_migration"
version = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
keywords = { workspace = true }
license = { workspace = true }
repository = { workspace = true }

[package.metadata.cargo-machete]
ignored = ["workspace-hack"]

[package.metadata.cargo-udeps.ignore]
normal = ["workspace-hack"]

[dependencies]
async-std = { version = "1", features = ["attributes", "tokio1"] }
uuid = { version = "1", features = ["v4"] }

[dependencies.sea-orm-migration]
version = "0.12.0"
features = ["sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", "runtime-tokio-native-tls", "with-uuid"]
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ use sea_orm_migration::prelude::*;

#[async_std::main]
async fn main() {
cli::run_cli(model_migration::Migrator).await;
cli::run_cli(risingwave_meta_model_migration::Migrator).await;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# How to define changes between versions and generate migration and model files

- Generate a new migration file and apply it to the database, check [migration](./migration/README.md) for more details. Let's take a local PG database as an example(`postgres://postgres:@localhost:5432/postgres`):
- Generate a new migration file and apply it to the database, check [migration](../migration/README.md) for more details. Let's take a local PG database as an example(`postgres://postgres:@localhost:5432/postgres`):
```sh
export DATABASE_URL=postgres://postgres:@localhost:5432/postgres;
cargo run -- generate MIGRATION_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use sea_orm::entity::prelude::*;

use crate::model_v2::I32Array;
use crate::I32Array;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "actor")]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use risingwave_pb::catalog::PbConnection;
use sea_orm::entity::prelude::*;
use sea_orm::ActiveValue;

use crate::model_v2::{ConnectionId, PrivateLinkService};
use crate::{ConnectionId, PrivateLinkService};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "connection")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use risingwave_pb::catalog::PbDatabase;
use sea_orm::entity::prelude::*;
use sea_orm::ActiveValue;

use crate::model_v2::DatabaseId;
use crate::DatabaseId;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "database")]
Expand Down Expand Up @@ -44,3 +46,12 @@ impl Related<super::object::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

impl From<PbDatabase> for ActiveModel {
fn from(db: PbDatabase) -> Self {
Self {
database_id: ActiveValue::Set(db.id),
name: ActiveValue::Set(db.name),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use sea_orm::entity::prelude::*;

use crate::model_v2::I32Array;
use crate::I32Array;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "fragment")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use risingwave_pb::catalog::PbFunction;
use sea_orm::entity::prelude::*;
use sea_orm::ActiveValue;

use crate::model_v2::{DataType, DataTypeArray, FunctionId};
use crate::{DataType, DataTypeArray, FunctionId};

#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(None)")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use sea_orm::entity::prelude::*;

use crate::model_v2::{ExprNodeArray, I32Array, IndexId, JobStatus, TableId};
use crate::{ExprNodeArray, I32Array, IndexId, JobStatus, TableId};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "index")]
Expand Down
2 changes: 0 additions & 2 deletions src/meta/src/model_v2/mod.rs → src/meta/model_v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub mod compaction_status;
pub mod compaction_task;
pub mod connection;
pub mod database;
pub mod ext;
pub mod fragment;
pub mod function;
pub mod hummock_pinned_snapshot;
Expand All @@ -42,7 +41,6 @@ pub mod sink;
pub mod source;
pub mod system_parameter;
pub mod table;
pub mod trx;
pub mod user;
pub mod user_privilege;
pub mod view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use sea_orm::entity::prelude::*;

use crate::model_v2::{DatabaseId, ObjectId, SchemaId, UserId};
use crate::{DatabaseId, ObjectId, SchemaId, UserId};

#[derive(Clone, Debug, PartialEq, Eq, Copy, EnumIter, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(None)")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use sea_orm::entity::prelude::*;

use crate::model_v2::{ObjectId, UserId};
use crate::{ObjectId, UserId};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "object_dependency")]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use risingwave_pb::catalog::PbSchema;
use sea_orm::entity::prelude::*;
use sea_orm::ActiveValue;

use crate::model_v2::SchemaId;
use crate::SchemaId;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "schema")]
Expand Down Expand Up @@ -43,3 +45,12 @@ impl Related<super::object::Entity> for Entity {
}

impl ActiveModelBehavior for ActiveModel {}

impl From<PbSchema> for ActiveModel {
fn from(schema: PbSchema) -> Self {
Self {
schema_id: ActiveValue::Set(schema.id),
name: ActiveValue::Set(schema.name),
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use risingwave_pb::catalog::PbSinkType;
use sea_orm::entity::prelude::*;

use crate::model_v2::{
use crate::{
ColumnCatalogArray, ColumnOrderArray, ConnectionId, I32Array, JobStatus, Property,
SinkFormatDesc, SinkId,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use sea_orm::entity::prelude::*;

use crate::model_v2::{
use crate::{
ColumnCatalogArray, ConnectionId, I32Array, Property, SourceId, StreamSourceInfo, TableId,
WatermarkDescArray,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use risingwave_pb::catalog::table::PbTableType;
use risingwave_pb::catalog::PbHandleConflictBehavior;
use sea_orm::entity::prelude::*;

use crate::model_v2::{
use crate::{
Cardinality, ColumnCatalogArray, ColumnOrderArray, CreateType, I32Array, JobStatus, Property,
SourceId, TableId, TableVersion,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use sea_orm::entity::prelude::*;

use crate::model_v2::UserId;
use crate::UserId;

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

use sea_orm::entity::prelude::*;

use crate::model_v2::{ObjectId, UserId};
use crate::{ObjectId, UserId};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_privilege")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use risingwave_pb::catalog::PbView;
use sea_orm::entity::prelude::*;
use sea_orm::ActiveValue;

use crate::model_v2::{FieldArray, Property, ViewId};
use crate::{FieldArray, Property, ViewId};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "view")]
Expand Down
Loading
Loading