async def METHOD_NAME(
    conn: SAConnection, fmd: FileMetaData | FileMetaDataAtDB
) -> FileMetaDataAtDB:
    # NOTE: upsert file_meta_data, if the file already exists, we update the whole row
    # so we get the correct time stamps
    fmd_db = FileMetaDataAtDB.from_orm(fmd) if isinstance(fmd, FileMetaData) else fmd
    insert_statement = pg_insert(file_meta_data).values(**jsonable_encoder(fmd_db))
    on_update_statement = insert_statement.on_conflict_do_update(
        index_elements=[file_meta_data.c.file_id], set_=jsonable_encoder(fmd_db)
    ).returning(literal_column("*"))
    result = await conn.execute(on_update_statement)
    row = await result.first()
    assert row  # nosec
    return FileMetaDataAtDB.from_orm(row)