Skip to content

Commit

Permalink
Simplify Migration Class Version Syntax
Browse files Browse the repository at this point in the history
Updated the syntax for defining migration versions from `self.version =` to a simpler and more concise `Cql::Migration(version)` format. This change promotes cleaner code and easier readability. Additionally, removed redundant schema definition examples from documentation to prevent confusion and enhance clarity.
  • Loading branch information
eliasjpr committed Aug 24, 2024
1 parent 46476b8 commit 3e03742
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 28 deletions.
4 changes: 1 addition & 3 deletions docs/Cql/Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ The `Migrator` class also provides methods to list applied and pending migration
**Example** Creating a new migration

```crystal
class CreateUsersTable < Cql::Migration
self.version = 1_i64
class CreateUsersTable < Cql::Migration(1)
def up
schema.alter :users do
add_column :name, String
Expand Down
8 changes: 0 additions & 8 deletions docs/Cql/Migrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ The `Migrator` class also provides methods to list applied and pending migration
**Example** Creating a new migrator

```crystal
schema = Cql::Schema.define(:northwind, "sqlite3://db.sqlite3") do |s|
table :schema_migrations do
primary :id, Int32
column :name, String
column :version, Int64, index: true, unique: true
timestamps
end
end
migrator = Cql::Migrator.new(schema)
```

Expand Down
8 changes: 2 additions & 6 deletions docs/coreconcepts/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ Migrations allow you to:
Let’s start with a simple example. Suppose we need to add a `users` table to our database with two columns: `name` and `age`.

```crystal
class CreateUsersTable < Cql::Migration
self.version = 1_i64
class CreateUsersTable < Cql::Migration(1)
def up
schema.alter :users do
add_column :name, String
Expand Down Expand Up @@ -158,9 +156,7 @@ This gives you details about the last migration that was successfully applied.
Here’s an example where we define multiple migrations and apply them sequentially:

```crystal
class CreateMoviesTable < Cql::Migration
self.version = 2_i64
class CreateMoviesTable < Cql::Migration(2)
def up
schema.alter :movies do
add_column :title, String
Expand Down
12 changes: 1 addition & 11 deletions src/migrations.cr
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ module Cql
# **Example** Creating a new migration
#
# ```
# class CreateUsersTable < Cql::Migration
# self.version = 1_i64
#
# class CreateUsersTable < Cql::Migration(1)
# def up
# schema.alter :users do
# add_column :name, String
Expand All @@ -35,14 +33,6 @@ module Cql
# **Example** Applying migrations
#
# ```
# schema = Cql::Schema.define(:northwind, "sqlite3://db.sqlite3") do |s|
# table :schema_migrations do
# primary :id, Int32
# column :name, String
# column :version, Int64, index: true, unique: true
# timestamps
# end
# end
# migrator = Cql::Migrator.new(schema)
# migrator.up
# ```
Expand Down

0 comments on commit 3e03742

Please sign in to comment.