Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support timestamps in hierarchy table #355

Open
eternal-engineer opened this issue Oct 23, 2019 · 0 comments
Open

support timestamps in hierarchy table #355

eternal-engineer opened this issue Oct 23, 2019 · 0 comments

Comments

@eternal-engineer
Copy link

in the auto generated migration for adding hierarchy table, we added timestamps. but on creating a new node, it is giving a

irb(main):002:0> FactoryBot.create(:team, parent_team_id: 1)
   (0.3ms)  BEGIN
  Team Exists (0.4ms)  SELECT  1 AS one FROM "teams" WHERE "teams"."name" = $1 LIMIT $2  [["name", "team_ac"], ["LIMIT", 1]]
  SQL (0.4ms)  INSERT INTO "teams" ("name", "created_at", "updated_at", "parent_team_id") VALUES ($1, $2, $3, $4) RETURNING "id"  [["name", "team_ac"], ["created_at", "2019-10-22 08:18:37.901023"], ["updated_at", "2019-10-22 08:18:37.901023"], ["parent_team_id", 1]]
  Team Load (0.3ms)  SELECT  "teams".* FROM "teams" WHERE "teams"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
   (0.3ms)  SELECT pg_try_advisory_lock(574075692,0) AS ta7593a24a94afc0487630a879bcaeecb /* 699637a87a17acedd4a1b2deb25dd53e7 */
  SQL (0.3ms)  INSERT INTO "team_hierarchies" ("ancestor_id", "descendant_id", "generations", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5)  [["ancestor_id", 2], ["descendant_id", 2], ["generations", 0], ["created_at", "2019-10-22 08:18:37.910341"], ["updated_at", "2019-10-22 08:18:37.910341"]]
   (1.5ms)  INSERT INTO "team_hierarchies"
  (ancestor_id, descendant_id, generations)
SELECT x.ancestor_id, 2, x.generations + 1
FROM "team_hierarchies" x
WHERE x.descendant_id = 1

   (1.0ms)  SELECT pg_advisory_unlock(574075692,0) AS t2c98fa71268f3a49c8d5496ebfc13008 /* 699637a87a17acedd4a1b2deb25dd53e7 */
   (0.2ms)  ROLLBACK
   (0.3ms)  SELECT pg_advisory_unlock(574075692,0) AS ta49a042f283a32125aef86ed4912fb91 /* 699637a87a17acedd4a1b2deb25dd53e7 */
   (0.2ms)  BEGIN
   (0.2ms)  ROLLBACK
Traceback (most recent call last):
        1: from (irb):2
ActiveRecord::NotNullViolation (PG::NotNullViolation: ERROR:  null value in column "created_at" violates not-null constraint
DETAIL:  Failing row contains (1, 2, 1, null, null).
: INSERT INTO "team_hierarchies"
  (ancestor_id, descendant_id, generations)
SELECT x.ancestor_id, 2, x.generations + 1
FROM "team_hierarchies" x
WHERE x.descendant_id = 1
)

the library is not passing timestamps. How do we go about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant