Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 28 17:13
    akadusei opened #386
  • Mar 28 14:42
  • Mar 28 14:17
    drujensen commented #1189
  • Mar 28 03:10
    andrewc910 edited #1189
  • Mar 28 03:09
    andrewc910 opened #1189
  • Mar 27 17:12
  • Mar 25 22:10
    akadusei edited #385
  • Mar 25 22:09
    akadusei edited #385
  • Mar 25 22:05
    akadusei opened #385
  • Mar 24 23:33

    drujensen on master

    Bump Kilt to latest version (#1… (compare)

  • Mar 24 23:33
    drujensen closed #1188
  • Mar 24 21:09
    andrewc910 commented #1188
  • Mar 24 21:09
    andrewc910 synchronize #1188
  • Mar 24 20:45
    drujensen commented #1188
  • Mar 24 20:14

    drujensen on v0.6.0

    (compare)

  • Mar 24 20:14

    drujensen on master

    update kilt to 0.6.0 (compare)

  • Mar 24 20:12
    drujensen commented #28
  • Mar 24 20:09

    drujensen on v0.5.5

    (compare)

  • Mar 24 20:05

    drujensen on v0.5.5

    (compare)

  • Mar 24 20:05

    drujensen on master

    update kilt shard (compare)

George Dietrich
@Blacksmoke16
what does the first migration look like?
Alexander
@Yashko
```
George Dietrich
@Blacksmoke16
im assuming its like
Alexander
@Yashko

-- +micrate Up
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMP,
updated_at TIMESTAMP
);

-- +micrate Down
DROP TABLE IF EXISTS users;

George Dietrich
@Blacksmoke16
right
so just add the SQL to add your new column?
or if you're still developing, alter the original until you get it in a good state then can down/up it
Alexander
@Yashko
Yes, i can do it. But it will be manually. I'm looking into whether amber have ability to do it automatically
George Dietrich
@Blacksmoke16
automatically based on the model definition?
Alexander
@Yashko
Right!
George Dietrich
@Blacksmoke16
i would doubt it
idt any framework has that feature
(in crystal)
Alexander
@Yashko
I mean it would be awesome if i will run lets say amber g model user, then make some adjustments to the models/user.cr and run amber g model user > keep all and it will create a migration based on the new model
George Dietrich
@Blacksmoke16
hmm yea idk, would have to run that past others
Alexander
@Yashko
why?
in case if you can afford just drop the old schema. Guess i will go and take a look at source, it doesn't sound like a complex matter
Because currently if developer need 10+ or even more columns it will be kinda unconvient to pass all of them to the amber g model user age:int etc
George Dietrich
@Blacksmoke16
because im not really involved in Amber core development
others are more familiar might have thoughts/suggestions
Alexander
@Yashko
Me neither, just found it by accident
Anyway thank you! <3
George Dietrich
@Blacksmoke16
np
Alexander
@Yashko
And so far as I can tell it's the best option for building robust applications on Crystal
btw do you know is this?
``<<-DEPENDENCY require "../src/models/**" DEPENDENCY
<<- this operator
Alexander
@Yashko
How it supposed to work? https://play.crystal-lang.org/#/r/8s7s
George Dietrich
@Blacksmoke16
it just a fancy syntax for making multi line strings
Interesting
George Dietrich
@Blacksmoke16
Right, it's just a string
Alexander
@Yashko
Any luck with crystal debug inside VS Code anyone?
Damian Hamill
@damianham
@Yashko at the moment there is no option to automatically modify database tables based on model fields, so (post public release) you need to create a migration to modify the table and add the column. As @Blacksmoke16 points out, prior to public release you should simply modify the migration that creates the table. It is almost an anti-pattern to create new table altering migrations prior to the first public release.
Dru Jensen
@drujensen
@Yashko At one point, I attempted to do what you are suggesting but it was clear this wouldn’t work. You need to support migrating from one column to another and there is no way of predicting what the developer intended to do. I tried an additive only approach but you would still need to go back and remove columns so it would require a two step process. Migrations are better in that they run in order and the database keeps track of what migration you are on so a database can be in any state and the migrations will run from that point forward.
However, It’s not as dry as your suggestion.
Jade Kharats
@JadeKharats
Hello! where to find the list of type for amber g model|scaffold? Example : amber g scaffold Event description:text date:datetime user:reference
Alexander
@Yashko
@JadeKharats Check out amber-stable/src/amber/cli/generators/field.cr, i think its there
image.png
Jade Kharats
@JadeKharats
@Yashko Thanks
Jade Kharats
@JadeKharats
another newbie question : How to test a controller when i put him in routes :auth

i suppose i should modify this block
`
class EventControllerTest < GarnetSpec::Controller::Test
getter handler : Amber::Pipe::Pipeline

def initialize
@handler = Amber::Pipe::Pipeline.new
@handler.build :web do
plug Amber::Pipe::Error.new
plug Amber::Pipe::Session.new
plug Amber::Pipe::Flash.new
end
@handler.prepare_pipelines
end
end
`
in my spec file.

but i don't know how?
Sam Johnson
@sam0x17
in granite how to get just the first record in a query?
George Dietrich
@Blacksmoke16
.first is a thing
er
.find_by, and find use .first under the hood
otherwise you can pass some raw sql to .first