-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Recover work * Add type-checking for better compile error * Fix compile errors * Allow passing a call * Do not use a second argument, use the value argument * Fix examples
- Loading branch information
1 parent
68cc0c6
commit a88fdbc
Showing
10 changed files
with
111 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class CreateDiscount::V20230128124355 < Avram::Migrator::Migration::V1 | ||
def migrate | ||
create :discounts do | ||
primary_key id : String | ||
add_timestamps | ||
add description : String | ||
add in_cents : Int32 | ||
add_belongs_to line_item : LineItem, on_delete: :cascade, foreign_key_type: UUID | ||
end | ||
end | ||
|
||
def rollback | ||
drop :discounts | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class DiscountFactory < BaseFactory | ||
def initialize | ||
description "Awesome discount" | ||
in_cents 99 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Discount < BaseModel | ||
skip_default_columns | ||
|
||
table do | ||
primary_key id : String = Random::Secure.hex | ||
timestamps | ||
column description : String | ||
column in_cents : Int32 | ||
belongs_to line_item : LineItem | ||
end | ||
end | ||
|
||
class DiscountQuery < Discount::BaseQuery | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/avram/migrator/columns/primary_keys/string_primary_key.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require "./base" | ||
|
||
module Avram::Migrator::Columns::PrimaryKeys | ||
class StringPrimaryKey < Base | ||
def initialize(@name) | ||
end | ||
|
||
def column_type : String | ||
"text" | ||
end | ||
|
||
def build : String | ||
%( #{name} #{column_type} PRIMARY KEY) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
enum Avram::PrimaryKeyType | ||
Serial | ||
UUID | ||
String | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters