How to add one to many relation to SeaORM migration table?

I'm writing the database migrations for this program based on this schema and I would like to add a field names to the File table. How can I do that?

https://www.sea-ql.org/sea-orm-tutorial/ch01-03-migration-api.html#define-the-migrations

wiki/src/migrator/m20220726_000001_create_file_table.rs

use sea_orm_migration::prelude::*;

pub struct Migration;

impl MigrationName for Migration {
    fn name(&self) -> &str {
        "m_20220726_000001_create_file_table"
    }

    #[async_trait::async_trait]
    impl MigrationTrait for Migration {
        async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
            manager
                .create_table(
                    Table::create()
                        .table(File::Table)
                        .col(
                            ColumnDef::new(File::Id)
                                .integer()
                                .not_null()
                                .auto_increment()
                                .primary_key(),
                        )
                        .col(ColumnDef::new(File::rating).double())
                        .to_owned(),
                )
                .await
        }
        async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
            manager
                .drop_table(Table::drop().table(File::Table).to_owned())
                .await
        }
}

#[derive(Iden)]
pub enum File {
    Table,
    Id,
    Rating,
}

I think I have to create another table for example FileName and create a foreign key in that table linking to the id of the File table.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.