<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.2">Jekyll</generator><link href="https://coffeejunk.dev/feed.xml" rel="self" type="application/atom+xml" /><link href="https://coffeejunk.dev/" rel="alternate" type="text/html" /><updated>2022-05-22T13:36:25+00:00</updated><id>https://coffeejunk.dev/feed.xml</id><title type="html">coffeejunk.dev</title><subtitle>Hey there! I&apos;m Max! On the internet I usually go by `coffeejunk`. I&apos;m a freelance software developer, work primarily with Ruby.</subtitle><entry><title type="html">PostgreSQL: search for fields starting or ending with whitespace</title><link href="https://coffeejunk.dev/til/2020/09/09/postgres-select-values-with-whitespace.html" rel="alternate" type="text/html" title="PostgreSQL: search for fields starting or ending with whitespace" /><published>2020-09-09T00:00:00+00:00</published><updated>2020-09-09T00:00:00+00:00</updated><id>https://coffeejunk.dev/til/2020/09/09/postgres-select-values-with-whitespace</id><content type="html" xml:base="https://coffeejunk.dev/til/2020/09/09/postgres-select-values-with-whitespace.html"><![CDATA[<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>select * from table_name where column_name ~ '^\s+|\s+$';
</code></pre></div></div>]]></content><author><name></name></author><category term="til" /><category term="postgres" /><summary type="html"><![CDATA[select * from table_name where column_name ~ '^\s+|\s+$';]]></summary></entry><entry><title type="html">Rails: reset postgres primary key sequence</title><link href="https://coffeejunk.dev/til/2020/09/09/reset-rails-primary-key-seq.html" rel="alternate" type="text/html" title="Rails: reset postgres primary key sequence" /><published>2020-09-09T00:00:00+00:00</published><updated>2020-09-09T00:00:00+00:00</updated><id>https://coffeejunk.dev/til/2020/09/09/reset-rails-primary-key-seq</id><content type="html" xml:base="https://coffeejunk.dev/til/2020/09/09/reset-rails-primary-key-seq.html"><![CDATA[<p>To reset the primary key sequence of a table in a PostgreSQL backed Ruby on
Rails application, run:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>ActiveRecord::Base.connection.reset_pk_sequence!('table_name')
</code></pre></div></div>

<p>The method is not publicly documented, but you can find more details in the
<a href="https://github.com/rails/rails/blob/070d4afacd3e9721b7e3a4634e4d026b5fa2c32c/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L273-L299">implementation</a>.</p>]]></content><author><name></name></author><category term="til" /><category term="rails" /><category term="postgres" /><summary type="html"><![CDATA[To reset the primary key sequence of a table in a PostgreSQL backed Ruby on Rails application, run:]]></summary></entry></feed>