Importar manteniendo los IDs de publicaciones antiguas en Discourse

The import script saves the import id in a post custom field. You can use it to create permalinks. Several importers do that. You can look at others for examples.