@ariga/atlas-provider-sequelize

中文文档
0.3.5发布于 2026/02/10ISC构建来源已验证近 30 天下载 1884

Load Sequelize models into an Atlas project.

原始使用文档
文档目录6 节
  1. Use-cases
  2. Installation
  3. Usage
  4. Supported Databases
  5. Issues
  6. License

atlas-provider-sequelize

Load Sequelize models into an Atlas project.

Use-cases

  1. Declarative migrations - use a Terraform-like atlas schema apply --env sequelize to apply your Sequelize schema to the database.
  2. Automatic migration planning - use atlas migrate diff --env sequelize to automatically plan a migration from the current database version to the Sequelize schema.

Installation

Install Atlas from macOS or Linux by running:

curl -sSf https://atlasgo.sh | sh

See atlasgo.io for more installation options.

Install the provider by running:

npm i @ariga/atlas-provider-sequelize

Make sure all your Node dependencies are installed by running:

npm i

Standalone

If all of your Sequelize models exist in a single Node module, you can use the provider directly to load your Sequelize schema into Atlas.

In your project directory, create a new file named atlas.hcl with the following contents:

data "external_schema" "sequelize" {
  program = [
    "npx",
    "@ariga/atlas-provider-sequelize",
    "load",
    "--path", "./path/to/models",
    "--dialect", "mysql", // mariadb | postgres | sqlite | mssql
  ]
}

env "sequelize" {
  src = data.external_schema.sequelize.url
  dev = "docker://mysql/8/dev"
  migration {
    dir = "file://migrations"
  }
  format {
    migrate {
      diff = "{{ sql . \"  \" }}"
    }
  }
}

As JS Script

If you want to use the provider as JS script, you can use the provider as follows:

Create a new file named load.js with the following contents:

#!/usr/bin/env node

// require sequelize models you want to load
const user = require("./models/user");
const task = require("./models/task");
const loadModels = require("@ariga/atlas-provider-sequelize");

console.log(loadModels("mysql", user, task));

Next, in your project directory, create a new file named atlas.hcl with the following contents:

data "external_schema" "sequelize" {
    program = [
        "node",
        "load.js",
    ]
}

env "sequelize" {
    src = data.external_schema.sequelize.url
    dev = "docker://mysql/8/dev"
    migration {
        dir = "file://migrations"
    }
    format {
        migrate {
            diff = "{{ sql . \"  \" }}"
        }
    }
}

Usage

Once you have the provider installed, you can use it to apply your Sequelize schema to the database:

Apply

You can use the atlas schema apply command to plan and apply a migration of your database to your current Sequelize schema. This works by inspecting the target database and comparing it to the Sequelize schema and creating a migration plan. Atlas will prompt you to confirm the migration plan before applying it to the database.

atlas schema apply --env sequelize -u "mysql://root:password@localhost:3306/mydb"

Where the -u flag accepts the URL to the target database.

Diff

Atlas supports a version migration workflow, where each change to the database is versioned and recorded in a migration file. You can use the atlas migrate diff command to automatically generate a migration file that will migrate the database from its latest revision to the current Sequelize schema.

atlas migrate diff --env sequelize

Supported Databases

The provider supports the following databases:

  • MySQL
  • MariaDB
  • PostgreSQL
  • SQLite
  • Microsoft SQL Server

Issues

Please report any issues or feature requests in the ariga/atlas repository.

License

This project is licensed under the Apache License 2.0.

版本与发布记录

@ariga/atlas-provider-sequelize 共发布 20 个版本,首次发布于 2023/09/10;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.5latest2026/02/108 个月前
0.3.42026/02/108 个月前
0.3.32025/06/161.4 年前
0.3.22025/06/121.4 年前
0.3.12025/06/101.4 年前
0.3.02025/06/091.4 年前

关于 @ariga/atlas-provider-sequelize 的常见问题

@ariga/atlas-provider-sequelize 是什么?

Load Sequelize models into an Atlas project.

如何安装 @ariga/atlas-provider-sequelize?

在项目目录运行 npm install @ariga/atlas-provider-sequelize,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:sequelize(^6.37.6)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。它还提供命令行工具 atlas-provider-sequelize,可以用 npx atlas-provider-sequelize 直接运行。

@ariga/atlas-provider-sequelize 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/ariga__atlas-provider-sequelize 是否存在。

@ariga/atlas-provider-sequelize 可以商用吗?

@ariga/atlas-provider-sequelize 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ariga/atlas-provider-sequelize 的下载量有多少?

根据 npm 官方下载统计,@ariga/atlas-provider-sequelize 在 2026/10/07 – 2026/11/05 这 30 天内被下载 1,884 次,日均约 63 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ariga/atlas-provider-sequelize 还在维护吗?

最新版本 0.3.5 发布于 2026/02/10(8 个月前);至今共发布 20 个版本,其中过去 12 个月发布了 2 个;首次发布于 2023/09/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。