data-migration 相关问题

数据迁移是数据从一个位置到另一个位置的移动,可以以多种形式和许多系统发生。数据迁移的一个示例是将数据从一个数据库复制到另一个数据库

如何将带有图像的内容从 Drupal 8 自动迁移到 Drupal 9 以实现单一内容类型?

如何将带有图像的内容从 Drupal 8 自动迁移到 Drupal 9 以获取单一内容类型(使用 Drush 命令)?

回答 2 投票 0

spring batch RepositoryItemWriter不将数据写入数据库

@配置 公共类数据源配置{ @豆 @ConfigurationProperties(“spring.datasource”) 公共数据源appDataSource() { DataSourceBuilder 构建器 =

回答 1 投票 0

使用两个数据源的 Spring 批处理

我正在开发一个 Spring Batch 项目,我需要使用两个不同的数据源。我计划使用 RepositoryItemReader 和 RepositoryItemWriter 来读取和写入这些数据库。哈...

回答 1 投票 0

用于工作流程数据迁移的 Spring 批处理

在执行数据迁移时,通常会涉及到需要从多个存储库中提取数据、转换数据然后保存到新存储库的工作流程。解决这个问题的一种方法...

回答 1 投票 0

如何将cosmosdb中的数据导出到.json文件

如何在不锁定表的情况下以安全的方式从 json 文件中的 cosmosdb 导出数据? 并希望能够通过查询仅从文档下载某些属性。

回答 2 投票 0

Azure 数据工厂,表存储副本二进制数据结果在 System.Byte[] 输出中

我们正在将大量数据从一个表存储移动到其他区域和订阅中的另一个表存储。 我已经设置了一个用于复制 Azure 数据工厂中的数据的管道,这似乎...

回答 2 投票 0

Azure 数据迁移工具第二次运行

我正在将本地 SQL Server 和数据库迁移到 Azure PaaS。我使用了微软的Azure数据迁移工具,创建了数据库并将数据复制到Azure环境中。它有效...

回答 1 投票 0

如何使用与 Django 中的自定义用户的关系创建*工作*数据迁移?

我刚刚开始了一个新项目,我正在使用自定义用户模型(来自 django-authtools)。一切都很完美,直到我厌倦了在擦除数据库后不断创建示例数据并决定......

回答 1 投票 0

对于允许从 mongoDB 中提取数据然后将其移动到同一产品的另一个环境的工具或任何其他方法的建议?

我正在开发一个具有不同环境的网站。数据管理工具是MongoDB。以前,我在环境 1 上运行自动化测试脚本,现在我必须在环境上执行此操作...

回答 1 投票 0

如何使用 Django 中的自定义用户关系创建*工作*数据迁移?

我刚刚开始了一个新项目,我正在使用自定义用户模型(来自 django-authtools)。一切都很完美,直到我厌倦了在擦除数据库后不断创建示例数据并决定......

回答 1 投票 0

Flyway回滚sql文件名约定

当使用“V1.0.0__Alter_Student_Schema.sql”作为回滚脚本时,它起作用了。但是,当使用“R1.0.0__Alter_Student_Schema.sql”或“U1.0.0__Alter_Student_Schema.sql”时,它会给出“2 个 SQL 迁移”

回答 1 投票 0

我刚刚学习 Laravel,我正在尝试实现一本书和一篇评论之间的一对多关系,但是播种失败,不知道为什么

书籍模型 书籍模型 <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Book extends Model { use HasFactory; public function reviews(){ // a book can have many reviews return $this->hasMany(Review::class); // i tried //return $this->hasMany(Review::class, 'book_id'); //but it didn't solve the problem } } 审查模型 <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Review extends Model { use HasFactory; public function books(){ // a review is tied to one book return $this->belongsTo(Book::class); // I tried //return $this->belongsTo(Book::class,'book_id'); //but it didn't work } } Book 模型的迁移文件 public function up() : void { Schema::create('books', function (Blueprint $table) { $table->id(); $table->string('title'); $table->string('author'); $table->timestamps(); }); } Review模型的迁移文件 public function up() : void { Schema::create('reviews', function (Blueprint $table) { $table->id(); $table->text('review'); $table->unsignedTinyInteger('rating'); $table->timestamps(); //?defining the foreign key // $table->unsignedBigInteger( 'book_id' ); // $table->foreign( 'book_id' ) ->references( 'id' )->on( 'books' )->onDelete( 'cascade' ); //?a shorter syntax $table->foreignId('book_id')->constrained()->cascadeOnDelete(); }); } BookFactory 文件 public function definition() : array { return [ 'title' => fake()->sentence(3), 'author' => fake()->name, 'created_at' => fake()->dateTimeBetween('-2 years'), 'updated_at' => fake()->dateTimeBetween('created_at', 'now') ]; } 评论工厂 class ReviewFactory extends Factory { /** * Define the model's default state. * * @return array<string, mixed> */ public function definition() : array { return [ 'book_id' => null, 'review' => fake()->paragraph, 'rating' => fake()->numberBetween(1, 5), 'created_at' => fake()->dateTimeBetween('-2 years'), 'updated_at' => fake()->dateTimeBetween('created_at', 'now') ]; } //? Create state methods to create more diversity in the generated data public function good(){ return $this->state(function (array $attributes) { return [ 'rating' => fake() -> numberBetween(4,5) ]; }); } public function average(){ return $this->state(function (array $attributes) { return [ 'rating' => fake() -> numberBetween(2,5) ]; }); } public function bad(){ return $this->state(function (array $attributes) { return [ 'rating' => fake() -> numberBetween(1,3) ]; }); } } DatabaseSeeder.php 文件 public function run() : void { Book::factory(34)->create()->each(function ($book) { $numReviews = random_int(5, 30); Review::factory() ->count($numReviews) //the number of the reviews generated ->good() // using the state method to define the 'rating' ->for($book) // associating the records to the current generated book ->create(); }); Book::factory(33)->create()->each(function ($book) { $numReviews = random_int(5, 30); Review::factory() ->count($numReviews) ->average() ->for($book) ->create(); }); Book::factory(33)->create()->each(function ($book) { $numReviews = random_int(5, 30); Review::factory() ->count($numReviews) ->bad() ->for($book) ->create(); }); } 运行“php artisan migrate:refresh --seed”时收到的错误消息 INFO Rolling back migrations. 2023_08_17_222856_create_reviews_table ...................................... 18ms DONE 2023_08_17_222848_create_books_table ......................................... 7ms DONE 2019_12_14_000001_create_personal_access_tokens_table ........................ 8ms DONE 2019_08_19_000000_create_failed_jobs_table ................................... 7ms DONE 2014_10_12_100000_create_password_reset_tokens_table ......................... 7ms DONE 2014_10_12_000000_create_users_table ......................................... 7ms DONE INFO Running migrations. 2014_10_12_000000_create_users_table ........................................ 33ms DONE 2014_10_12_100000_create_password_reset_tokens_table ........................ 36ms DONE 2019_08_19_000000_create_failed_jobs_table .................................. 24ms DONE 2019_12_14_000001_create_personal_access_tokens_table ....................... 34ms DONE 2023_08_17_222848_create_books_table ......................................... 9ms DONE 2023_08_17_222856_create_reviews_table ...................................... 45ms DONE INFO Seeding database. Illuminate\Database\QueryException SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'book_id' cannot be null (Connection: mysql, SQL: insert into `reviews` (`book_id`, `review`, `rating`, `created_at`, `updated_at`) values (?, Officiis consequatur temporibus maxime sequi laudantium et. Nam non voluptas est ea. Id fugit et amet deserunt ullam laborum eveniet. Harum eos ratione voluptate debitis qui sequi., 5, 2022-11-02 05:18:02, 2022-12-06 12:41:24)) at vendor\laravel\framework\src\Illuminate\Database\Connection.php:795 791▕ // If an exception occurs when attempting to run a query, we'll format the error 792▕ // message to include the bindings with SQL, which will make this exception a 793▕ // lot more helpful to the developer instead of just the database's errors. 794▕ catch (Exception $e) { ➜ 795▕ throw new QueryException( 796▕ $this->getName(), $query, $this->prepareBindings($bindings), $e 797▕ ); 798▕ } 799▕ } 1 vendor\laravel\framework\src\Illuminate\Database\Connection.php:580 PDOException::("SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'book_id' cannot be null") 2 vendor\laravel\framework\src\Illuminate\Database\Connection.php:580 PDOStatement::execute() 我原本希望找到 100 本书,每本书有 5 到 30 条评论,但当我检查 phpMyAdmin 时,我发现只有 34 本书被种子化,而且根本没有评论被种子化,但我发现外键列已添加到评论表中。 好吧,这里有很多东西要解压。 在您的审查模型中,所属函数的名称应该是单数。所以它是 book() 不是 books()。 您忘记注释掉审核迁移文件中的 ->references( 'id' )->on( 'books' )->onDelete( 'cascade' ); 行。 在您的 Book- 和 ReviewFactory 中,您有 faker()->name 和 faker()->paragraph ,它们应该是函数,所以 faker()->name() 和 faker()->paragraph() 在您的 Book- 和 ReviewFactory 中,您有 fake()->dateTimeBetween('-2 years')。我不是 100% 舒尔,但我认为它应该采用 0 或 2 个参数,例如 fake()->dateTimeBetween('-2 years', 'now') ...这就是您的错误消息的来源。在您的 ReviewFactory 中您有 'book_id' => null。只需删除这一行即可。 在 DatabaseSeeder 中,您的代码可能如下所示: public function run(): void { $book = Book::factory(34) ->has(Review::factory()->count(random_int(5, 30)), 'reviews') ->create(); }

回答 1 投票 0

Rails - 在特定环境中跳过 data_migrations

我正在编写一个 data_migration,我正在使用 data-migrate gem。我遇到一种情况,我应该单独在生产环境中跳过一个特定的 data_migration 。我可以这样做 班级

回答 1 投票 0

SQL Server 从非规范化表迁移到规范化表导致性能问题

我们的 SQL Server 数据模型中有一个非规范化表,我们希望将其迁移到规范化格式。但是,我们为此迁移创建的查询导致了严重的延迟。我们有

回答 0 投票 0

将数据从一个 Oracle 模式中的表迁移到另一个 Oracle 模式(在列等方面存在差异)

我们正在从当前的中提取和重写一些功能 将应用程序转换为具有自己的 Oracle 模式的微服务。 新应用程序具有不同的架构,因此我们必须迁移 ...

回答 0 投票 0

Hashicorp Vault 从存储类型`file` 迁移到`raft`

我正在尝试将在我们的 RKE2 集群中运行的具有存储类型文件的独立 Hashicorp Vault 迁移到具有存储类型 raft 的 Hashicorp Vault HA。但仍然遇到一些问题。我们正在使用...

回答 1 投票 0

在线重新分区现有表

表架构 我有一个按天分区的分区表“解决方案”,如下所示: 解决方案: 解决方案_20230115 解决方案_20230116 解决方案_20230117 ... 解决方案_20230314 解决方案_20230315

回答 1 投票 0

我正在使用 MySQL 的 GCP 数据流到使用 python 的 CDC 的 GCS,我可以创建流但无法使用 datastream_v1alpha1 运行流

在这里输入图片描述 stream = datastream_v1alpha1.Stream( display_name='MySQL转gcs流', source_config = source_config, destination_config = destination_config,backfill_all=

回答 0 投票 0

AWS ElastiCache 内存数据迁移到 MemoryDB 集群

我有一个 ElastiCache 集群 (AWS),我想将我的数据迁移到 MemoryDB 集群(也在 AWS 中)。使用 ElastiCache 快照为 MemoryDB 集群播种会覆盖持久数据,但不会...

回答 0 投票 0

如何在 VBA 中转义 PostgreSQL 的数据库表名和列名?

我正在尝试将Access数据库迁移到PostgreSQL数据库,并且很多表名或列名都有空格或数字,例如表名:“测试历史”和“123人&曲...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.