Hello All, How do I change the heroku database( already existed ) table id to start from say 1000? I tried with a fresh database on local & it works with this:- *execute "ALTER users orders AUTO_INCREMENT = 1000"* Thanks, Avinash -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/R2RtfuEQ9NoJ. For more options, visit https://groups.google.com/groups/opt_out.
On Tuesday, March 12, 2013 4:28:59 PM UTC+5:30, Avi wrote:> > Hello All, > > How do I change the heroku database( already existed ) table id to start > from say 1000? > > I tried with a fresh database on local & it works with this:- > *execute "ALTER users orders AUTO_INCREMENT = 1000"* >> > Sorry - this query - *execute "SELECT setval(''users_id_seq'', 1000)"* >The above query is db already existed.> > > Thanks, > Avinash > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/5JszMUGr27gJ. For more options, visit https://groups.google.com/groups/opt_out.
On 12 March 2013 10:58, Avi <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello All, > > How do I change the heroku database( already existed ) table id to start > from say 1000?Don''t bother. You should never care what the id is for a record, it will just make life difficult if you do. If you want a column with a meaningful number in it then add an extra column rather than using the id. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
The main reason I am doing this is :- I am uploading some images to s3 amazon. I am saving those images in s3 through rake script. I have two tables having images. Both are saving in one folder in s3. I want to save those based on ids, so that there will not be any conflict. On Tue, Mar 12, 2013 at 4:35 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 12 March 2013 10:58, Avi <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello All, > > > > How do I change the heroku database( already existed ) table id to start > > from say 1000? > > Don''t bother. You should never care what the id is for a record, it > will just make life difficult if you do. If you want a column with a > meaningful number in it then add an extra column rather than using the > id. > > Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Thanks & Regards, *Avinash Behera* *M-09538712979* -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 12 March 2013 12:58, avinash behera <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The main reason I am doing this is :- > I am uploading some images to s3 amazon. > I am saving those images in s3 through rake script. > I have two tables having images. > Both are saving in one folder in s3. > I want to save those based on ids, so that there will not be any conflict.I don''t understand what you mean, do you mean you have two tables and want to keep the ids of the two tables distinct from each other? If so then that is a bad idea, it will be sure to cause you problems at some time in the future. A better idea might be to have a third table (images) that manages all the images and has a relationship to the other tables. Possibly polymorphic (see http://guides.rubyonrails.org/association_basics.html#polymorphic-associations ). Colin> > On Tue, Mar 12, 2013 at 4:35 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> On 12 March 2013 10:58, Avi <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > Hello All, >> > >> > How do I change the heroku database( already existed ) table id to start >> > from say 1000? >> >> Don''t bother. You should never care what the id is for a record, it >> will just make life difficult if you do. If you want a column with a >> meaningful number in it then add an extra column rather than using the >> id. >> >> Colin >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > > > -- > Thanks & Regards, > Avinash Behera > M-09538712979 > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Tue, Mar 12, 2013 at 7:58 AM, avinash behera <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The main reason I am doing this is :- > I am uploading some images to s3 amazon. > I am saving those images in s3 through rake script. > I have two tables having images. > Both are saving in one folder in s3.Do you mean they are being saved to the same bucket? Or do you mean a path under the bucket? S3 has it''s own very unique method of storage. But you can easily store things in the same bucket, but specify a path-like prefix: s3://mybucket/table1/image-n.jpg s3://mybucket/table2/image-n.jpg table1 and table2 aren''t really folders in S3, but they''re good enough emulation to consider that for most uses.> I want to save those based on ids, so that there will not be any conflict.As stated, don''t rely on the record ID in your database. Create a unique id for each image if you''d like, and use that to tag it, if that''s how you want to go. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
So, my requirement is :- I have an Image table & a related_image table. image has_many related_images. & related_images belongs to many images. Those images in both the tables are in sequence(we can change the sequence- That will be a problem in case of belongs to many images). So, this seems to be a better option to save images as id. In s3, I am saving both the images(images & related_images) in one folder as <id>.png or <id>.jpg After saving into s3, there are some other process to do like creating .plist file from the json objects & others. Here I require those data from s3. I was getting an interesting issue with heroku. I was doing a db:reset & set the default id to start with 1000 & 10000 respectively. It was working for the first time. If I do again a db:reset it goes. It starts from 1. I fixed it by adding migration file with :- def change execute "SELECT setval(''images_id_seq'', 1000)" end def change execute "SELECT setval(''related_images_id_seq'', 10000)" end & on console by :- heroku pg:reset DATABASE --confirm MY_APP_NAME So, now every time I reset, I need to run the migration & it works. On Wed, Mar 13, 2013 at 2:16 AM, tamouse mailing lists < tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Mar 12, 2013 at 7:58 AM, avinash behera > <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > The main reason I am doing this is :- > > I am uploading some images to s3 amazon. > > I am saving those images in s3 through rake script. > > I have two tables having images. > > Both are saving in one folder in s3. > > Do you mean they are being saved to the same bucket? Or do you mean a > path under the bucket? S3 has it''s own very unique method of storage. > But you can easily store things in the same bucket, but specify a > path-like prefix: > > s3://mybucket/table1/image-n.jpg > s3://mybucket/table2/image-n.jpg > > table1 and table2 aren''t really folders in S3, but they''re good enough > emulation to consider that for most uses. > > > I want to save those based on ids, so that there will not be any > conflict. > > As stated, don''t rely on the record ID in your database. Create a > unique id for each image if you''d like, and use that to tag it, if > that''s how you want to go. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Thanks, *Avinash* -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On Mar 14, 2013 1:58 AM, "avinash behera" <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > So, my requirement is :- > > I have an Image table & a related_image table. > image has_many related_images. > & related_images belongs to many images. > Those images in both the tables are in sequence(we can change thesequence- That will be a problem in case of belongs to many images).> > So, this seems to be a better option to save images as id. > In s3, I am saving both the images(images & related_images) in one folderas <id>.png or <id>.jpg> > After saving into s3, there are some other process to do like creating.plist file from the json objects & others. Here I require those data from s3.> > I was getting an interesting issue with heroku. > I was doing a db:reset & set the default id to start with 1000 & 10000respectively.> It was working for the first time. If I do again a db:reset it goes. Itstarts from 1.> > I fixed it by adding migration file with :- > def change > execute "SELECT setval(''images_id_seq'', 1000)" > end > def change > execute "SELECT setval(''related_images_id_seq'', 10000)" > end > > & on console by :- heroku pg:reset DATABASE --confirm MY_APP_NAME > > So, now every time I reset, I need to run the migration & it works. > > > On Wed, Mar 13, 2013 at 2:16 AM, tamouse mailing lists <tamouse.lists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:>> >> On Tue, Mar 12, 2013 at 7:58 AM, avinash behera >> <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > The main reason I am doing this is :- >> > I am uploading some images to s3 amazon. >> > I am saving those images in s3 through rake script. >> > I have two tables having images. >> > Both are saving in one folder in s3. >> >> Do you mean they are being saved to the same bucket? Or do you mean a >> path under the bucket? S3 has it''s own very unique method of storage. >> But you can easily store things in the same bucket, but specify a >> path-like prefix: >> >> s3://mybucket/table1/image-n.jpg >> s3://mybucket/table2/image-n.jpg >> >> table1 and table2 aren''t really folders in S3, but they''re good enough >> emulation to consider that for most uses. >> >> > I want to save those based on ids, so that there will not be anyconflict.>> >> As stated, don''t rely on the record ID in your database. Create a >> unique id for each image if you''d like, and use that to tag it, if >> that''s how you want to go. >> >> -- >> You received this message because you are subscribed to the GoogleGroups "Ruby on Rails: Talk" group.>> To unsubscribe from this group and stop receiving emails from it, sendan email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > > > -- > Thanks, > Avinash > > -- > You received this message because you are subscribed to the Google Groups"Ruby on Rails: Talk" group.> To unsubscribe from this group and stop receiving emails from it, send anemail to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > >Are images also capable of being related images? And vice versa? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
On 14 March 2013 06:57, avinash behera <aavinash.behera-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So, my requirement is :- > > I have an Image table & a related_image table. > image has_many related_images. > & related_images belongs to many images. > Those images in both the tables are in sequence(we can change the sequence- > That will be a problem in case of belongs to many images). > > So, this seems to be a better option to save images as id. > In s3, I am saving both the images(images & related_images) in one folder as > <id>.png or <id>.jpg > > After saving into s3, there are some other process to do like creating > .plist file from the json objects & others. Here I require those data from > s3. > > I was getting an interesting issue with heroku. > I was doing a db:reset & set the default id to start with 1000 & 10000 > respectively. > It was working for the first time. If I do again a db:reset it goes. It > starts from 1.I can''t say I exactly follow what you want, but I still suggest not to use the id. Using the id causes problems as you have found out. Instead simply add another field (image_id for example) and set it to whatever values you want, independent of the id. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.