本文へスキップ
Skillpedia
データベース18k · #10629

datatables

できること

このスキルは、マイグレーションが有効な場合に順序付きのマイグレーションを使って、Windmillのデータテーブルのスキーマを変更する方法と、そのロールと権限の仕組みを説明します。Windmillで共有データベースを管理する人向けです。

使う場面

  • ✓Windmillのデータテーブルの列やその他のスキーマを追加、変更、削除する必要があるとき。
  • ✓マイグレーションが有効で、対応するダウンマイグレーションとともにアップマイグレーションを書く必要があるとき。
  • ✓データテーブルにロールや権限を設定する必要があるとき。

スキルのリンク

https://github.com/windmill-labs/windmill/blob/main/system_prompts/auto-generated/skills/datatables/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/windmill-labs/windmill/blob/main/system_prompts/auto-generated/skills/datatables/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“Windmillの顧客データテーブルに新しい列を追加してください。その変更がマイグレーションとして記録されるようにしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

スキルは、マイグレーションが有効なとき、スキーマの変更をバージョン付きのマイグレーションとして記録するようエージェントに指示します。そうすることで、変更がワークスペースとともに移動し、取り消せます。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Data tables: schema changes, migrations and permissions

A data table is a PostgreSQL database managed by Windmill and shared by the whole workspace: scripts, flows and apps reach it by name, main being the default. It is configured in the workspace settings (Data Tables), never created by SQL.

Changing the schema

A data table with migrations enabled keeps its schema as an ordered list of versioned SQL migrations, each an up and an optional down. That list is what git sync and a workspace merge carry, and what rebuilds the schema in another workspace. So first find out whether migrations are enabled on the data table:

  • Enabled: make every schema change (CREATE, ALTER, DROP, anything but row data) as a new migration. A change made with plain SQL exists in that one database only, and the history no longer describes it.
  • Not enabled: schema changes are plain SQL. Enabling migrations is a workspace admin's decision, made in the Data Tables settings, not a step to take on the way to something else.

Writing a migration:

  • Wrap the statements in BEGIN; ... END; so it applies atomically. Leave the frame out only for a statement that cannot run in a transaction, such as CREATE INDEX CONCURRENTLY: such a migration can fail half applied.
  • Give it a down that undoes the up whenever the change is reversible. Without one it cannot be rolled back.
  • Declare the schemas it changes on a leading line of its up, -- schemas sales, billing, and qualify every name with its schema (sales.orders). A migration waits only on earlier migrations whose schemas overlap its own. One that declares none applies to the whole database and every later migration waits for it, so leave the line out only for a change that really spans the database, such as an extension.
  • Migrations apply oldest first. One that is applied is not edited: correct it with a new migration.
  • Row data is not schema. Insert, update and delete rows with plain SQL, migrations or not.

wmill datatable migrate new <name> scaffolds migrations/datatable/<datatable>/<timestamp>_<name>.up.sql and .down.sql, wmill datatable migrate up pushes the local files and applies what is pending, wmill datatable migrate down rolls back the most recent one and wmill datatable migrate status lists them. All take -d <datatable> and default to main. migrate new --schemas sales,billing writes the -- schemas line, and migrate up --schema sales applies only the pending migrations declaring that schema.

A migration is not a draft

A migration is saved to the workspace and changes the database as soon as it is applied, for everything that reads those tables. To try a schema out without touching tables already in use:

  • put the new tables in a schema of their own, created by the same migration (CREATE SCHEMA IF NOT EXISTS), and point what you are building at it. A raw app names its schema in its data config, which is why a new app gets a new schema by default;
  • or work in a workspace fork whose data table was cloned when the fork was created ("Clone schema only" or "Clone schema and data"): migrations applied there change that copy alone, and reach the parent workspace when the fork is merged. A fork that kept the original data table points at the parent's database, so a migration applied in it changes the parent's tables at once.

Altering or dropping a table other scripts or apps use is neither of those: say what depends on it before doing it.

Roles and permissions

Data table roles are a self-hosted Enterprise Edition feature, for data tables on managed Postgres (the instance database or the external managed instance). Without them, and always on a data table backed by a Postgres resource, everyone who can use the data table reaches all of it: there is no per-user, per-schema or per-row access to promise.

A data table under roles is reached as a Postgres role, and Postgres enforces what that role was granted:

  • roles are assigned, per data table, to users, groups or folders. admin is the connection the data table had before roles: it owns the existing objects and ignores grants;
  • a connection either names a role (wmill.datatable('main', { role: 'analyst' }), role='analyst' in Python, datatable://main?role=analyst) and holds that role alone, or names none and is resolved from the data table's default role;
  • permission denied means the role in use lacks a grant. Say which role and which object: the grant is a data ta
よくある質問

ただのSQLを実行してはいけないのですか?

マイグレーションが有効なとき、ただのSQLの変更は1つのデータベースにしか存在せず、マイグレーションの履歴と一致しなくなるためです。

ダウンマイグレーションとは何ですか?

アップマイグレーションを取り消すステップで、変更を元に戻せるようにするものです。

マイグレーションを有効にするのは誰ですか?

ワークスペースの管理者が、データテーブルの設定でこれを決めます。

詳細

作者による元の説明

MUST use when changing a data table's schema, writing or running its migrations, or working with its roles and permissions.

repo: windmill-labs/windmill

人気

GitHubのスター
18k
ランキング
#10629
ライセンス
—
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル